vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 85260a25843afcb4e763f1e8fa2a0f1e4edb227a parent b479111c480acaf0979021c7b827709036dabf2d Author: Marc André Tanner <mat@brain-dump.org> Date: Wed, 20 Jan 2016 12:53:33 +0100 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:
| M | vis.c | | | 6 | ++++++ |
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git 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);