aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-08-14 15:52:11 +0200
committerGitHub <noreply@github.com>2019-08-14 15:52:11 +0200
commit0c952c1c8b4eca74998d1cabbe798f3f7eaa5f03 (patch)
tree4d3620d1f262254bedff6f1050398793f6602d33
parent5ad67af3c1884cd81a06986c4516c8a210bd7418 (diff)
parentba0aaf012a819d56a36d695fe02eaed820be81ff (diff)
downloadrneovim-0c952c1c8b4eca74998d1cabbe798f3f7eaa5f03.tar.gz
rneovim-0c952c1c8b4eca74998d1cabbe798f3f7eaa5f03.tar.bz2
rneovim-0c952c1c8b4eca74998d1cabbe798f3f7eaa5f03.zip
Merge pull request #10757 from bfredl/compfix
compositor: handle invalid screen positions after resize gracefully
-rw-r--r--src/nvim/screen.c2
-rw-r--r--src/nvim/ui_compositor.c22
2 files changed, 21 insertions, 3 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 99ccce1793..1b2143c419 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -4375,7 +4375,7 @@ static void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol,
screen_adjust_grid(&grid, &row, &coloff);
// Safety check. Avoids clang warnings down the call stack.
- if (grid->chars == NULL || row >= grid->Rows || col >= grid->Columns) {
+ if (grid->chars == NULL || row >= grid->Rows || coloff >= grid->Columns) {
DLOG("invalid state, skipped");
return;
}
diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c
index 2cb3cf7ee7..9517b362af 100644
--- a/src/nvim/ui_compositor.c
+++ b/src/nvim/ui_compositor.c
@@ -480,8 +480,26 @@ static void ui_comp_raw_line(UI *ui, Integer grid, Integer row,
if (curgrid != &default_grid) {
flags = flags & ~kLineFlagWrap;
}
- assert(row < default_grid.Rows);
- assert(clearcol <= default_grid.Columns);
+
+ assert(endcol <= clearcol);
+
+ // TODO(bfredl): this should not really be necessary. But on some condition
+ // when resizing nvim, a window will be attempted to be drawn on the older
+ // and possibly larger global screen size.
+ if (row >= default_grid.Rows) {
+ DLOG("compositor: invalid row %"PRId64" on grid %"PRId64, row, grid);
+ return;
+ }
+ if (clearcol > default_grid.Columns) {
+ DLOG("compositor: invalid last column %"PRId64" on grid %"PRId64,
+ clearcol, grid);
+ if (startcol >= default_grid.Columns) {
+ return;
+ }
+ clearcol = default_grid.Columns;
+ endcol = MIN(endcol, clearcol);
+ }
+
if (flags & kLineFlagInvalid
|| kv_size(layers) > curgrid->comp_index+1
|| curgrid->blending) {