From cb515157b3258fc21ac6a54876db1061501765e5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 1 Apr 2021 23:17:13 +0530 Subject: [PATCH] Fix the selection getting changed if the screen contents scroll while the selection is in progress When the selection object was refactored to track the input co-ordinates, index_selection() was not updated accordingly. Fixes #3431 --- docs/changelog.rst | 3 +++ kitty/screen.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 36e74f58f..3fa92b234 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -108,6 +108,9 @@ To update |kitty|, :doc:`follow the instructions `. - Fix marking of text not working on lines that contain zero cells (:iss:`3403`) +- Fix the selection getting changed if the screen contents scroll while + the selection is in progress (:iss:`3431`) + 0.19.3 [2020-12-19] ------------------- diff --git a/kitty/screen.c b/kitty/screen.c index 52b77d00b..1672facff 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -225,12 +225,20 @@ index_selection(const Screen *self, Selections *selections, bool up) { if (!is_selection_empty(s)) { if (up) { if (s->start.y == 0) s->start_scrolled_by += 1; - else s->start.y--; + 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++; + 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++; }