aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-01-20 12:53:33 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-01-20 12:53:33 +0100
commita552b071a0f88153ba5ff462fcdf4461ff4f2a16 (patch)
treeb860b85d18e031314426bf7defeaa9082736cc82 /vis.c
parent0d4093c3371079c5f75055338f0341f684542465 (diff)
downloadvis-a552b071a0f88153ba5ff462fcdf4461ff4f2a16.tar.gz
vis-a552b071a0f88153ba5ff462fcdf4461ff4f2a16.tar.xz
vis: further improve selection restore code
This is still not 100% correct for all possible cases, but should work for those currently used by vis e.g. the shift left operator.
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/vis.c b/vis.c
index aceb0ed..f4ad2e4 100644
--- a/vis.c
+++ b/vis.c
@@ -527,6 +527,12 @@ void action_do(Vis *vis, Action *a) {
Filerange sel = view_cursors_selection_get(cursor);
view_cursors_to(cursor, pos);
if (vis->mode->visual) {
+ if (sel.start == EPOS && sel.end == EPOS)
+ sel = c.range;
+ else if (sel.start == EPOS)
+ sel = text_range_new(c.range.start, sel.end);
+ else if (sel.end == EPOS)
+ sel = text_range_new(c.range.start, sel.start);
if (vis->mode == &vis_modes[VIS_MODE_VISUAL_LINE])
sel = text_range_linewise(txt, &sel);
view_cursors_selection_set(cursor, &sel);