aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-02-21 22:35:43 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-02-21 22:35:43 +0000
commita1b5862db21ab0ae52ba2e8314be46432eac5225 (patch)
tree976f7a90e488de20fd83049858e11c41f7e487f9
parentkeymap: tab: handle all modifiers (diff)
scroll-up: ensure view is valid after adjusting an overshot scrollback
When we scroll up, we need to ensure that we don't scroll too far, "past" the scrollback limit. I.e. we need to ensure we don't wrap around. The code did this. But, in certain scenarios, the resulting view points into uninitialized scrollback history. This happens when we haven't yet filled the entire scrollback, and scroll up enough lines to wrap around the scrollback. The old code would adjust the view for the wrap around, but doing so pointed the view at the not-yet utilized scrollback.
-rw-r--r--commands.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/commands.c b/commands.c
index 572dae68..53d0dfb3 100644
--- a/commands.c
+++ b/commands.c
@@ -55,6 +55,9 @@ cmd_scrollback_up(struct terminal *term, int rows)
new_view = end + 1;
}
+ while (term->grid->rows[new_view] == NULL)
+ new_view = (new_view + 1) % term->grid->num_rows;
+
#if defined(_DEBUG)
for (int r = 0; r < term->rows; r++)
assert(term->grid->rows[(new_view + r) % term->grid->num_rows] != NULL);