Skip to content

Commit

Permalink
Merge pull request #820 from techee/vi_fix
Browse files Browse the repository at this point in the history
vimode: Fix repeated commands like 10dd not working
  • Loading branch information
frlan authored Mar 24, 2019
2 parents 0654842 + 47e1658 commit 55a25bb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
22 changes: 17 additions & 5 deletions vimode/src/cmd-runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,18 @@ static gboolean is_cmdpart(GSList *kpl, CmdDef *cmds)
}


static gboolean is_printable(GSList *kpl)
{
guint mask = GDK_MODIFIER_MASK & ~(GDK_SHIFT_MASK | GDK_LOCK_MASK);
KeyPress *kp = g_slist_nth_data(kpl, 0);

if (kp->modif & mask)
return FALSE;

return g_unichar_isprint(gdk_keyval_to_unicode(kp->key));
}


static CmdDef *get_cmd_to_run(GSList *kpl, CmdDef *cmds, gboolean have_selection)
{
gint i;
Expand Down Expand Up @@ -609,7 +621,7 @@ static gboolean perform_repeat_cmd(CmdContext *ctx)
}


static gboolean process_cmd(CmdDef *cmds, CmdContext *ctx)
static gboolean process_cmd(CmdDef *cmds, CmdContext *ctx, gboolean ins_mode)
{
gboolean consumed;
gboolean performed = FALSE;
Expand All @@ -618,7 +630,7 @@ static gboolean process_cmd(CmdDef *cmds, CmdContext *ctx)
SSM(ctx->sci, SCI_GETSELECTIONEND, 0, 0) - SSM(ctx->sci, SCI_GETSELECTIONSTART, 0, 0) > 0;
CmdDef *def = get_cmd_to_run(ctx->kpl, cmds, have_selection);

consumed = is_cmdpart(ctx->kpl, cmds);
consumed = is_cmdpart(ctx->kpl, cmds) || (!ins_mode && is_printable(ctx->kpl));

if (def)
{
Expand Down Expand Up @@ -667,17 +679,17 @@ static gboolean process_cmd(CmdDef *cmds, CmdContext *ctx)

gboolean cmd_perform_cmd(CmdContext *ctx)
{
return process_cmd(cmd_mode_cmds, ctx);
return process_cmd(cmd_mode_cmds, ctx, FALSE);
}


gboolean cmd_perform_vis(CmdContext *ctx)
{
return process_cmd(vis_mode_cmds, ctx);
return process_cmd(vis_mode_cmds, ctx, FALSE);
}


gboolean cmd_perform_ins(CmdContext *ctx)
{
return process_cmd(ins_mode_cmds, ctx);
return process_cmd(ins_mode_cmds, ctx, TRUE);
}
12 changes: 0 additions & 12 deletions vimode/src/vi.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,6 @@ void vi_set_active_sci(ScintillaObject *sci)
}


static gboolean is_printable(GdkEventKey *ev)
{
guint mask = GDK_MODIFIER_MASK & ~(GDK_SHIFT_MASK | GDK_LOCK_MASK);

if (ev->state & mask)
return FALSE;

return g_unichar_isprint(gdk_keyval_to_unicode(ev->keyval));
}


gboolean vi_notify_key_press(GdkEventKey *event)
{
ScintillaObject *sci = ctx.sci;
Expand All @@ -244,7 +233,6 @@ gboolean vi_notify_key_press(GdkEventKey *event)
consumed = cmd_perform_cmd(&ctx);
else
consumed = cmd_perform_vis(&ctx);
consumed = consumed || is_printable(event);
}
else //insert, replace mode
{
Expand Down

0 comments on commit 55a25bb

Please sign in to comment.