mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
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:
parent
e8197d22f7
commit
a1b5862db2
1 changed files with 3 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue