commit 1ad9cdd4036b3d22798045843113d12e6edf8b7f
parent 40351bbbbe7891db9bdeb0d6c3bd95e2e0309775
Author: bfredl <bjorn.linse@gmail.com>
Date: Thu, 1 May 2025 21:09:38 +0200
fix(grid): check allocated grid size when suspicious scrolling
fixes #33749
Diffstat:
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
@@ -2527,21 +2527,26 @@ void win_scroll_lines(win_T *wp, int row, int line_count)
return;
}
- // No lines are being moved, just draw over the entire area
- if (row + abs(line_count) >= wp->w_view_height) {
- return;
- }
-
int col = 0;
int row_off = 0;
ScreenGrid *grid = grid_adjust(&wp->w_grid, &row_off, &col);
+ // TODO(bfredl): this is due to the call in curs_columns(). We really don't want to
+ // fiddle with the screen outside of update_screen() like this.
+ int checked_width = MIN(grid->cols - col, wp->w_view_width);
+ int checked_height = MIN(grid->rows - row_off, wp->w_view_height);
+
+ // No lines are being moved, just draw over the entire area
+ if (row + abs(line_count) >= checked_height) {
+ return;
+ }
+
if (line_count < 0) {
grid_del_lines(grid, row + row_off, -line_count,
- wp->w_view_height + row_off, col, wp->w_view_width);
+ checked_height + row_off, col, checked_width);
} else {
grid_ins_lines(grid, row + row_off, line_count,
- wp->w_view_height + row_off, col, wp->w_view_width);
+ checked_height + row_off, col, checked_width);
}
}