vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit fcf0271b7e0a4d8fc94ce166829ffbaa78847852 parent 1d1629740b194138481a5fdab6d8a450119badc0 Author: Marc André Tanner <mat@brain-dump.org> Date: Tue, 13 Jun 2017 15:26:04 +0200 view: fix view_selections_set The anchor needs to be set after the cursor was positioned, otherwise the cursor placement will immediately destroy the selection for in the non-anchored case. Diffstat:
| M | view.c | | | 10 | ++-------- |
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/view.c b/view.c @@ -1220,14 +1220,8 @@ void view_selections_set(Selection *s, const Filerange *r) { size_t end = r->end; if (r->start != end) end = text_char_prev(txt, end); - if (left_extending) { - s->anchor = text_mark_set(txt, end); - s->cursor = text_mark_set(txt, r->start); - } else { - s->anchor = text_mark_set(txt, r->start); - s->cursor = text_mark_set(txt, end); - } - view_cursors_to(s, text_mark_get(s->view->text, s->cursor)); + view_cursors_to(s, left_extending ? r->start : end); + s->anchor = text_mark_set(txt, left_extending ? end : r->start); } void view_selections_save(Selection *s) {