aboutsummaryrefslogtreecommitdiff
path: root/terminal.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-08-05 18:16:17 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-08-05 18:16:17 +0000
commitc06f141189c51450be3bfd896b9df7a9d423e79d (patch)
treefc4eb71fed2db196e8a766ec991faab0c9a24c7c /terminal.c
parentselection: ensure start < end in finalize (diff)
term: cancel selection when scrolling wraps
If we scroll enough, we'll eventually end up wrapping around the entire scrollback buffer. At this point, a selection is no longer valid, so cancel it. Note: this was very obvious when scrolling in the alt screen, since its scrollback buffer is what you see on the screen (i.e. it has no scrollback).
Diffstat (limited to 'terminal.c')
-rw-r--r--terminal.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/terminal.c b/terminal.c
index e8811ce5..622cd47a 100644
--- a/terminal.c
+++ b/terminal.c
@@ -282,8 +282,11 @@ term_scroll_partial(struct terminal *term, struct scroll_region region, int rows
grid_swap_row(term->grid, i - rows, i);
/* Erase scrolled in lines */
- for (int r = max(region.end - rows, 0); r < region.end; r++)
+ for (int r = max(region.end - rows, 0); r < region.end; r++) {
erase_line(term, grid_row(term->grid, r));
+ if (selection_on_row_in_view(term, r))
+ selection_cancel(term);
+ }
term_damage_scroll(term, DAMAGE_SCROLL, region, rows);
term->grid->cur_row = grid_row(term->grid, term->cursor.row);
@@ -325,8 +328,11 @@ term_scroll_reverse_partial(struct terminal *term,
grid_swap_row(term->grid, i, i - rows);
/* Erase scrolled in lines */
- for (int r = region.start; r < min(region.start + rows, region.end); r++)
+ for (int r = region.start; r < min(region.start + rows, region.end); r++) {
erase_line(term, grid_row(term->grid, r));
+ if (selection_on_row_in_view(term, r))
+ selection_cancel(term);
+ }
term_damage_scroll(term, DAMAGE_SCROLL_REVERSE, region, rows);
term->grid->cur_row = grid_row(term->grid, term->cursor.row);