diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index 800572ae06..f3919ace58 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -1367,6 +1367,12 @@ static void draw_sep_connectors_win(win_T *wp) /// bot: from bot_start to last row (when scrolled up) static void win_update(win_T *wp) { + // Return early when the windows would overflow the shrunk terminal window + // avoiding invalid drawing an assert failure + if (wp->w_grid.target == &default_grid && wp->w_wincol >= Columns) { + return; + } + int top_end = 0; // Below last row of the top area that needs // updating. 0 when no top area updating. int mid_start = 999; // first row of the mid area that needs diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 295c40b9b6..b105a5296e 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -2,7 +2,7 @@ local t = require('test.testutil') local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local set_session, clear = n.set_session, n.clear +local set_session, clear, assert_alive = n.set_session, n.clear, n.assert_alive local feed, command = n.feed, n.command local exec = n.exec local insert = n.insert @@ -646,6 +646,20 @@ local function screen_tests(linegrid) ]]) end) + it('does not crash when windows fill the screen #33883', function() + screen:try_resize(80, 20) + while true do + local ok = pcall(command, 'wincmd v') + if not ok then + break + end + end + + screen:try_resize(60, 20) + + assert_alive() + end) + it('clamps &cmdheight for current tabpage', function() command('set cmdheight=10 laststatus=2') screen:expect([[