diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-01-19 10:49:02 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-01-19 10:49:02 +0100 |
| commit | e247d57ccda74f765b1a71dba9d9c2e5c582acc4 (patch) | |
| tree | 1a19993b091edda1ad8a2ae1f8e586b5dfabc5fe /vis-modes.c | |
| parent | dd8b8b31ccd53991f263a78d1903d1c295546db5 (diff) | |
| download | vis-e247d57ccda74f765b1a71dba9d9c2e5c582acc4.tar.gz vis-e247d57ccda74f765b1a71dba9d9c2e5c582acc4.tar.xz | |
vis: simplify count handling for insertion
Diffstat (limited to 'vis-modes.c')
| -rw-r--r-- | vis-modes.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/vis-modes.c b/vis-modes.c index 991b21b..84f2e0b 100644 --- a/vis-modes.c +++ b/vis-modes.c @@ -139,21 +139,17 @@ static void vis_mode_normal_enter(Vis *vis, Mode *old) { if (old != mode_get(vis, VIS_MODE_INSERT) && old != mode_get(vis, VIS_MODE_REPLACE)) return; macro_operator_stop(vis); - if (vis->action_prev.op == &vis_operators[VIS_OP_MODESWITCH] && !vis->repeat_input) { - vis->repeat_input = true; - if (vis->action_prev.count > 1) { - /* temporarily disable motion, in something like `5atext` - * we should only move the cursor once then insert the text */ - const Movement *motion = vis->action_prev.movement; - if (motion) - vis->action_prev.movement = &vis_motions[VIS_MOVE_NOP]; - /* we already inserted the text once, so temporarily decrease count */ - vis->action_prev.count--; - vis_repeat(vis); - vis->action_prev.count++; - vis->action_prev.movement = motion; - } - vis->repeat_input = false; + if (vis->action_prev.op == &vis_operators[VIS_OP_MODESWITCH] && vis->action_prev.count > 1) { + /* temporarily disable motion, in something like `5atext` + * we should only move the cursor once then insert the text */ + const Movement *motion = vis->action_prev.movement; + if (motion) + vis->action_prev.movement = &vis_motions[VIS_MOVE_NOP]; + /* we already inserted the text once, so temporarily decrease count */ + vis->action_prev.count--; + vis_repeat(vis); + vis->action_prev.count++; + vis->action_prev.movement = motion; } /* make sure we can recover the current state after an editing operation */ vis_file_snapshot(vis, vis->win->file); |
