aboutsummaryrefslogtreecommitdiff
path: root/selection.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-10-14 16:03:00 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-10-16 08:31:15 +0000
commit89744f8123aadd58b74ea7b5038c3302c1ed75ed (patch)
treef2e0eeda299a5f3be6a756fc5f7014d530b4864e /selection.c
parentterm: reverse scroll: free scrolled out lines (diff)
selection: scroll down: handle non-full scrollback correctly
When determining whether or not to cancel a selection (due to it, or part of it, being "scrolled out"), we assumed the scrollback was full. This patch changes the implementation to compare the scrollback relative selection coordinates with the scrollback relative end-of-the-scrollback coordinates.
Diffstat (limited to 'selection.c')
-rw-r--r--selection.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/selection.c b/selection.c
index c94686e1..92f1f85f 100644
--- a/selection.c
+++ b/selection.c
@@ -133,13 +133,18 @@ selection_scroll_down(struct terminal *term, int rows)
{
xassert(term->selection.coords.end.row >= 0);
+ const struct grid *grid = term->grid;
+ const struct range *sel = &term->selection.coords;
+
+ const int screen_end =
+ grid_row_abs_to_sb(grid, term->rows, grid->offset + term->rows - 1);
const int rel_row_start =
- grid_row_abs_to_sb(term->grid, term->rows, term->selection.coords.start.row);
+ grid_row_abs_to_sb(term->grid, term->rows, sel->start.row);
const int rel_row_end =
- grid_row_abs_to_sb(term->grid, term->rows, term->selection.coords.end.row);
+ grid_row_abs_to_sb(term->grid, term->rows, sel->end.row);
const int actual_end = max(rel_row_start, rel_row_end);
- if (actual_end + rows <= term->grid->num_rows) {
+ if (actual_end > screen_end - rows) {
/* Part of the selection will be scrolled out, cancel it */
selection_cancel(term);
}