diff --git a/vimode/src/cmd-runner.c b/vimode/src/cmd-runner.c index d56324b50..dccafbfba 100644 --- a/vimode/src/cmd-runner.c +++ b/vimode/src/cmd-runner.c @@ -633,14 +633,25 @@ static gboolean perform_repeat_cmd(CmdContext *ctx) gint i; def = get_cmd_to_run(ctx->repeat_kpl, edit_cmds, FALSE); - if (!def) - return FALSE; - num = num == -1 ? 1 : num; - for (i = 0; i < num; i++) - perform_cmd(def, ctx); + if (def) { + for (i = 0; i < num; i++) + perform_cmd(def, ctx); + return TRUE; + } + else if (ctx->insert_buf_len > 0) { + gint pos; + + SSM(ctx->sci, SCI_BEGINUNDOACTION, 0, 0); + for (i = 0; i < num; i++) + SSM(ctx->sci, SCI_ADDTEXT, ctx->insert_buf_len, (sptr_t) ctx->insert_buf); + pos = SSM(ctx->sci, SCI_GETCURRENTPOS, 0, 0); + SET_POS(ctx->sci, PREV(ctx->sci, pos), FALSE); + SSM(ctx->sci, SCI_ENDUNDOACTION, 0, 0); + return TRUE; + } - return TRUE; + return FALSE; } diff --git a/vimode/src/context.h b/vimode/src/context.h index 3d60b39aa..d25573c9b 100644 --- a/vimode/src/context.h +++ b/vimode/src/context.h @@ -22,7 +22,7 @@ #include "vi.h" #include "sci.h" -#define INSERT_BUF_LEN 4096 +#define INSERT_BUF_LEN 131072 typedef struct { @@ -54,7 +54,7 @@ typedef struct gint num; /* buffer used in insert/replace mode to record entered text so it can be - * copied N times when e.g. 'i' is preceded by a number */ + * copied N times when e.g. 'i' is preceded by a number or when using '.' */ gchar insert_buf[INSERT_BUF_LEN]; gint insert_buf_len; } CmdContext; diff --git a/vimode/src/vi.c b/vimode/src/vi.c index bf7d65e1e..f5b6c9496 100644 --- a/vimode/src/vi.c +++ b/vimode/src/vi.c @@ -109,8 +109,6 @@ static void repeat_insert(gboolean replace) SSM(sci, SCI_ENDUNDOACTION, 0, 0); } ctx.num = 1; - ctx.insert_buf_len = 0; - ctx.insert_buf[0] = '\0'; ctx.newline_insert = FALSE; } @@ -156,6 +154,10 @@ void vi_set_mode(ViMode mode) gint start_pos = SSM(sci, SCI_POSITIONFROMLINE, GET_CUR_LINE(sci), 0); if (pos > start_pos) SET_POS(sci, PREV(sci, pos), FALSE); + + /* erase kpl so '.' command repeats last inserted text and not command */ + g_slist_free_full(ctx.kpl, g_free); + ctx.kpl = NULL; } else if (VI_IS_VISUAL(prev_mode)) SSM(sci, SCI_SETEMPTYSELECTION, pos, 0);