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.
This commit is contained in:
Daniel Eklöf 2020-02-21 23:35:43 +01:00
parent e8197d22f7
commit a1b5862db2
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -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);