From a552b071a0f88153ba5ff462fcdf4461ff4f2a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 20 Jan 2016 12:53:33 +0100 Subject: 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. --- vis.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'vis.c') 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); -- cgit v1.2.3