From 917350f0588640fd41ff2e02defdaf27f7017e95 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Feb 2020 21:10:09 +0530 Subject: [PATCH] Fix incorrect rendering of selection when using rectangular select and scrolling Fixes #2351 --- docs/changelog.rst | 3 +++ kitty/screen.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 780497d92..cf26dac77 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -36,6 +36,9 @@ To update |kitty|, :doc:`follow the instructions `. - Fix rendering of combining characters with fonts that have glyphs for precomposed characters but not decomposed versions (:iss:`2365`) +- Fix incorrect rendering of selection when using rectangular select and + scrolling (:iss:`2351`) + 0.16.0 [2020-01-28] -------------------- diff --git a/kitty/screen.c b/kitty/screen.c index 58ebe6114..d25542c86 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1557,13 +1557,13 @@ is_selection_empty(Screen *self, unsigned int start_x, unsigned int start_y, uns } static inline void -selection_coord(Screen *self, unsigned int x, unsigned int y, unsigned int ydelta, SelectionBoundary *ans) { +selection_coord(const Screen *self, unsigned int x, unsigned int y, unsigned int ydelta, SelectionBoundary *ans) { if (y + self->scrolled_by < ydelta) { - ans->x = 0; ans->y = 0; + ans->x = x; ans->y = 0; } else { y = y - ydelta + self->scrolled_by; if (y >= self->lines) { - ans->x = self->columns - 1; ans->y = self->lines - 1; + ans->x = MIN(x, self->columns - 1); ans->y = self->lines - 1; } else { ans->x = x; ans->y = y; }