aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-01-31 18:14:36 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-01-31 18:14:36 +0100
commit2ac88768ec2a643fe4a91f1bcde476fb5ec662c8 (patch)
treea2dc5ba65767950ab4e22aa3731b29b40d203c73
parentef21a35b0797ab272010d86456614458a7667d24 (diff)
downloadvis-2ac88768ec2a643fe4a91f1bcde476fb5ec662c8.tar.gz
vis-2ac88768ec2a643fe4a91f1bcde476fb5ec662c8.tar.xz
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
-rw-r--r--vis.c4
1 files changed, 4 insertions, 0 deletions
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);
}
}