From a13f8155918de3d8c520997aa2dfc079deefb249 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 3 Apr 2021 10:48:43 +0530 Subject: [PATCH] Fix index_selection() not updating empty selections Newly created selections are empty but must still be indexed. Fixes #3431 --- kitty/screen.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/kitty/screen.c b/kitty/screen.c index c0518a9ff..61820107e 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -222,26 +222,24 @@ static inline void index_selection(const Screen *self, Selections *selections, bool up) { for (size_t i = 0; i < selections->count; i++) { Selection *s = selections->items + i; - if (!is_selection_empty(s)) { - if (up) { - if (s->start.y == 0) s->start_scrolled_by += 1; - else { - s->start.y--; - if (s->input_start.y) s->input_start.y--; - if (s->input_current.y) s->input_current.y--; - } - if (s->end.y == 0) s->end_scrolled_by += 1; - else s->end.y--; - } else { - if (s->start.y >= self->lines - 1) s->start_scrolled_by -= 1; - else { - s->start.y++; - if (s->input_start.y < self->lines - 1) s->input_start.y++; - if (s->input_current.y < self->lines - 1) s->input_current.y++; - } - if (s->end.y >= self->lines - 1) s->end_scrolled_by -= 1; - else s->end.y++; + if (up) { + if (s->start.y == 0) s->start_scrolled_by += 1; + else { + s->start.y--; + if (s->input_start.y) s->input_start.y--; + if (s->input_current.y) s->input_current.y--; } + if (s->end.y == 0) s->end_scrolled_by += 1; + else s->end.y--; + } else { + if (s->start.y >= self->lines - 1) s->start_scrolled_by -= 1; + else { + s->start.y++; + if (s->input_start.y < self->lines - 1) s->input_start.y++; + if (s->input_current.y < self->lines - 1) s->input_current.y++; + } + if (s->end.y >= self->lines - 1) s->end_scrolled_by -= 1; + else s->end.y++; } } }