From 2ac88768ec2a643fe4a91f1bcde476fb5ec662c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 31 Jan 2017 18:14:36 +0100 Subject: vis: improve cursor positioning after operators in visual mode Make sure the selection setting code (used to restore selections) does not move the cursor. Fix #479 --- vis.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vis.c b/vis.c index e0b2c1e..3d9cad7 100644 --- a/vis.c +++ b/vis.c @@ -819,6 +819,10 @@ void vis_do(Vis *vis) { sel = text_range_new(c.range.start, sel.start); if (vis->mode == &vis_modes[VIS_MODE_VISUAL_LINE]) sel = text_range_linewise(txt, &sel); + if (!text_range_contains(&sel, pos)) { + Filerange cur = text_range_new(pos, pos); + sel = text_range_union(&sel, &cur); + } view_cursors_selection_set(cursor, &sel); } } -- cgit v1.2.3