Skip to content

Commit

Permalink
view: fix view_selections_set
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
martanne committed Jun 15, 2017
1 parent 21adfe4 commit fdc73f0
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions view.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit fdc73f0

Please sign in to comment.