From a4f593812385b1a4d9db4bd6a9fd12cc3064ebbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 16 May 2020 23:44:54 +0200 Subject: [PATCH] term: scrolling: clamp number of rows to number of rows in scrolling region --- CHANGELOG.md | 3 ++- terminal.c | 16 ++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b6470e3..49fb6b5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ * Copy to clipboard/primary selection to insert a line break if either the last cell on the previous line or the first cell on the next line is empty. +* Number of lines to scroll is now always clamped to the number of + lines in the scrolling region.. ### Deprecated ### Removed @@ -35,7 +37,6 @@ released. * Selected cells did not appear selected if modified. - ### Security diff --git a/terminal.c b/terminal.c index 9686d237..3cec6e44 100644 --- a/terminal.c +++ b/terminal.c @@ -1728,12 +1728,8 @@ term_scroll_partial(struct terminal *term, struct scroll_region region, int rows LOG_DBG("scroll: rows=%d, region.start=%d, region.end=%d", rows, region.start, region.end); -#if 0 - if (rows > region.end - region.start) { - /* For now, clamp */ - rows = region.end - region.start; - } -#endif + /* Clamp scroll amount */ + rows = min(rows, region.end - region.start); const int begin_scrolled_in = max(region.end - rows, region.start); const int end_scrolled_in = region.end; @@ -1778,12 +1774,8 @@ term_scroll_reverse_partial(struct terminal *term, LOG_DBG("scroll reverse: rows=%d, region.start=%d, region.end=%d", rows, region.start, region.end); -#if 0 - if (rows > region.end - region.start) { - /* For now, clamp */ - rows = region.end - region.start; - } -#endif + /* Clamp scroll amount */ + rows = min(rows, region.end - region.start); /* Row numbers of "new" lines scrolled in */ const int start_scrolled_in = region.start;