From 0592fd5e17dc3609c148e0ccc25a4f035d5f7153 Mon Sep 17 00:00:00 2001 From: nwounkn Date: Sun, 24 Sep 2023 23:15:33 +0500 Subject: [PATCH] fix(ui): "resize -1" with cmdheight=0 #24758 Problem: Crash from: set cmdheight=0 redrawdebug=invalid resize -1 Solution: Do not invalidate first `p_ch` `msg_grid` rows in `update_screen` when scrolling the screen down after displaying a message, because they may be used later for drawing cmdline. Fixes #22154 --- src/nvim/drawscreen.c | 2 +- test/functional/ui/cmdline_spec.lua | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index ee1f03e296..04918e9979 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -471,7 +471,7 @@ int update_screen(void) // non-displayed part of msg_grid is considered invalid. for (int i = 0; i < MIN(msg_scrollsize(), msg_grid.rows); i++) { grid_clear_line(&msg_grid, msg_grid.line_offset[i], - msg_grid.cols, false); + msg_grid.cols, i < p_ch); } } msg_grid.throttled = false; diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 6baad28dad..497b2e7f4c 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -1021,6 +1021,26 @@ describe('cmdheight=0', function() screen:attach() end) + it("with redrawdebug=invalid resize -1", function() + command("set redrawdebug=invalid cmdheight=0 noruler laststatus=0") + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + feed(":resize -1") + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + assert_alive() + end) + it("with cmdheight=1 noruler laststatus=2", function() command("set cmdheight=1 noruler laststatus=2") screen:expect{grid=[[