From a3751f5de22f7780d25cca77b23e690915a789a9 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 1 Jun 2023 11:44:08 +0200 Subject: [PATCH 1/3] fix(api): dont change curwin for nvim_win_set_height --- src/nvim/api/window.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index abe11e6b72..bc6d40acc3 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -167,13 +167,8 @@ void nvim_win_set_height(Window window, Integer height, Error *err) return; } - win_T *savewin = curwin; - curwin = win; - curbuf = curwin->w_buffer; try_start(); - win_setheight((int)height); - curwin = savewin; - curbuf = curwin->w_buffer; + win_setheight_win((int)height, win); try_end(err); } From 68e7a6a6dccff344f880e85e4e9f87104904c8a8 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 1 Jun 2023 12:23:42 +0200 Subject: [PATCH 2/3] test: added tests for set_height with winminheight=0 and a winbar --- test/functional/api/window_spec.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index a6d1807961..55d4ff6b2e 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -285,6 +285,22 @@ describe('API/win', function() eq(2, window('get_height', nvim('list_wins')[2])) end) + it('correctly handles height=1', function() + nvim('command', 'split') + nvim('set_current_win', nvim('list_wins')[1]) + window('set_height', nvim('list_wins')[2], 1) + eq(1, window('get_height', nvim('list_wins')[2])) + end) + + it('correctly handles height=1 with a winbar', function() + nvim('command', 'set winbar=foobar') + nvim('command', 'set winminheight=0') + nvim('command', 'split') + nvim('set_current_win', nvim('list_wins')[1]) + window('set_height', nvim('list_wins')[2], 1) + eq(1, window('get_height', nvim('list_wins')[2])) + end) + it('do not cause ml_get errors with foldmethod=expr #19989', function() insert([[ aaaaa From 1ff4562502e146d6da051b1adae925197b418493 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 1 Jun 2023 12:42:06 +0200 Subject: [PATCH 3/3] fix(api): dont change curwin for nvim_win_set_width --- src/nvim/api/window.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index bc6d40acc3..c021fec220 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -209,13 +209,8 @@ void nvim_win_set_width(Window window, Integer width, Error *err) return; } - win_T *savewin = curwin; - curwin = win; - curbuf = curwin->w_buffer; try_start(); - win_setwidth((int)width); - curwin = savewin; - curbuf = curwin->w_buffer; + win_setwidth_win((int)width, win); try_end(err); }