From 1f44e63071206bf9933737374ab703cb4768b5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 18 Jan 2017 17:57:02 +0100 Subject: vis: fix count handling for append Fix #371 --- vis.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'vis.c') diff --git a/vis.c b/vis.c index f3864d1..9f7d22c 100644 --- a/vis.c +++ b/vis.c @@ -683,6 +683,8 @@ void vis_do(Vis *vis) { vis_mode_switch(vis, VIS_MODE_VISUAL_LINE); int count = MAX(a->count, 1); + if (a->op == &vis_operators[VIS_OP_MODESWITCH]) + count = 1; /* count should apply to inserted text not motion */ bool repeatable = a->op && !vis->macro_operator && !vis->win->parent; bool multiple_cursors = view_cursors_multiple(view); bool linewise = !(a->type & CHARWISE) && ( @@ -1276,7 +1278,6 @@ bool vis_macro_replay(Vis *vis, enum VisRegister id) { } void vis_repeat(Vis *vis) { - int count = vis->action.count; Macro *macro_operator = macro_get(vis, VIS_MACRO_OPERATOR); Macro *macro_repeat = macro_get(vis, VIS_MACRO_REPEAT); const Macro *macro = vis->action_prev.macro; @@ -1285,21 +1286,22 @@ void vis_repeat(Vis *vis) { macro = macro_repeat; vis->action_prev.macro = macro; } + int count = vis->action.count; if (count != VIS_COUNT_UNKNOWN) vis->action_prev.count = count; - count = vis->action_prev.count; - /* for some operators count should be applied only to the macro not the motion */ - if (vis->action_prev.op == &vis_operators[VIS_OP_MODESWITCH]) - vis->action_prev.count = 1; + else + count = vis->action_prev.count; vis->action = vis->action_prev; vis_do(vis); - vis->action_prev.count = count; if (macro) { Mode *mode = vis->mode; Action action_prev = vis->action_prev; - count = action_prev.count; - if (count < 1 || action_prev.op == &vis_operators[VIS_OP_CHANGE] || action_prev.op == &vis_operators[VIS_OP_FILTER]) + if (count < 1 || + action_prev.op == &vis_operators[VIS_OP_CHANGE] || + action_prev.op == &vis_operators[VIS_OP_FILTER]) count = 1; + if (vis->action_prev.op == &vis_operators[VIS_OP_MODESWITCH]) + vis->action_prev.count = 1; for (int i = 0; i < count; i++) { mode_set(vis, mode); macro_replay(vis, macro); -- cgit v1.2.3