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
This commit is contained in:
Kovid Goyal
2021-04-01 23:17:13 +05:30
parent da39fb2880
commit cb515157b3
2 changed files with 13 additions and 2 deletions

View File

@@ -108,6 +108,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- 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]
-------------------

View File

@@ -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++;
}