From fdc73f01e040047a74d7323ca777055e061ec343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 13 Jun 2017 15:26:04 +0200 Subject: 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. --- view.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'view.c') diff --git a/view.c b/view.c index 14cc4aa..18882c6 100644 --- 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) { -- cgit v1.2.3