aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/window.c2
-rw-r--r--test/functional/ui/winbar_spec.lua9
2 files changed, 10 insertions, 1 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 916c193469..3022dccb1c 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -6634,7 +6634,7 @@ void win_set_inner_size(win_T *wp, bool valid_cursor)
int prev_height = wp->w_height_inner;
int height = wp->w_height_request;
if (height == 0) {
- height = wp->w_height - wp->w_winbar_height;
+ height = MAX(0, wp->w_height - wp->w_winbar_height);
}
if (height != prev_height) {
diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua
index d1fd273dc1..09338eb7d2 100644
--- a/test/functional/ui/winbar_spec.lua
+++ b/test/functional/ui/winbar_spec.lua
@@ -540,6 +540,15 @@ describe('winbar', function()
]])
eq('Vim(set):E36: Not enough room', pcall_err(command, 'set winbar=test'))
end)
+
+ it('does not crash due to negative grid height #33176', function()
+ screen:try_resize(screen._width, 20)
+ command('botright split | belowright vsplit | 2wincmd w')
+ api.nvim_set_option_value('winfixheight', true, { scope = 'local', win = 0 })
+ api.nvim_win_set_height(0, 8)
+ feed('q:')
+ n.assert_alive()
+ end)
end)
describe('local winbar with tabs', function()