mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-02 07:15:31 -04:00
render: reflow: bug: fix off-by-one
The 'last-row' variable points to the last row the cursor is *on*, thus it's not a counter, and we need to add one when calculating the new grid offsets, or we get an off-by-one error. With this, there's no longer any need to scroll the reflowed text.
This commit is contained in:
parent
d11a71e0b2
commit
9e6404be11
1 changed files with 7 additions and 6 deletions
13
render.c
13
render.c
|
|
@ -1150,8 +1150,8 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
|
||||||
|
|
||||||
/* Reset offset such that the last copied row ends up at the
|
/* Reset offset such that the last copied row ends up at the
|
||||||
* bottom of the screen */
|
* bottom of the screen */
|
||||||
term->normal.offset = last_normal_row - new_rows;
|
term->normal.offset = last_normal_row - new_rows + 1;
|
||||||
term->alt.offset = last_alt_row - new_rows;
|
term->alt.offset = last_alt_row - new_rows + 1;
|
||||||
|
|
||||||
/* Can't have negative offsets, so wrap 'em */
|
/* Can't have negative offsets, so wrap 'em */
|
||||||
while (term->normal.offset < 0)
|
while (term->normal.offset < 0)
|
||||||
|
|
@ -1165,6 +1165,7 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
|
||||||
while (alt[term->alt.offset] == NULL)
|
while (alt[term->alt.offset] == NULL)
|
||||||
term->alt.offset = (term->alt.offset + 1) & (new_alt_grid_rows - 1);
|
term->alt.offset = (term->alt.offset + 1) & (new_alt_grid_rows - 1);
|
||||||
|
|
||||||
|
/* TODO: try to keep old view */
|
||||||
term->normal.view = term->normal.offset;
|
term->normal.view = term->normal.offset;
|
||||||
term->alt.view = term->alt.offset;
|
term->alt.view = term->alt.offset;
|
||||||
|
|
||||||
|
|
@ -1234,14 +1235,14 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
|
||||||
while (cursor_row < 0)
|
while (cursor_row < 0)
|
||||||
cursor_row += term->grid->num_rows;
|
cursor_row += term->grid->num_rows;
|
||||||
|
|
||||||
|
assert(cursor_row >= 0);
|
||||||
|
assert(cursor_row < term->rows);
|
||||||
|
|
||||||
term_cursor_to(
|
term_cursor_to(
|
||||||
term,
|
term,
|
||||||
min(max(cursor_row, 0), term->rows - 1),
|
cursor_row,
|
||||||
min(term->cursor.point.col, term->cols - 1));
|
min(term->cursor.point.col, term->cols - 1));
|
||||||
|
|
||||||
if (cursor_row >= term->rows)
|
|
||||||
term_linefeed(term);
|
|
||||||
|
|
||||||
term->render.last_cursor.cell = NULL;
|
term->render.last_cursor.cell = NULL;
|
||||||
tll_free(term->normal.scroll_damage);
|
tll_free(term->normal.scroll_damage);
|
||||||
tll_free(term->alt.scroll_damage);
|
tll_free(term->alt.scroll_damage);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue