diff options
Diffstat (limited to 'grid.c')
| -rw-r--r-- | grid.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -984,6 +984,26 @@ grid_resize_and_reflow( /* Set offset such that the last reflowed row is at the bottom */ grid->offset = new_row_idx - new_screen_rows + 1; + + if (new_col_idx == 0) { + int next_to_last_new_row_idx = new_row_idx - 1; + next_to_last_new_row_idx += new_rows; + next_to_last_new_row_idx &= new_rows - 1; + + const struct row *next_to_last_row = new_grid[next_to_last_new_row_idx]; + if (next_to_last_row != NULL && next_to_last_row->linebreak) { + /* + * The next to last row is actually the *last* row. But we + * ended the reflow with a line-break, causing an empty + * row to be inserted at the bottom. Undo this. + */ + /* TODO: can we detect this in the reflow loop above instead? */ + grid->offset--; + grid_row_free(new_grid[new_row_idx]); + new_grid[new_row_idx] = NULL; + } + } + while (grid->offset < 0) grid->offset += new_rows; while (new_grid[grid->offset] == NULL) |
