diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-06-03 18:12:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-03 18:12:24 +0200 |
commit | 72300feecfbdd7e313ffb06442d6e80989028ac5 (patch) | |
tree | 897778ed0ea147eabc470858a26145372d9568c7 | |
parent | 0e01e815520ead73b13277b68306cf03a2196ca5 (diff) | |
parent | 1ff4562502e146d6da051b1adae925197b418493 (diff) | |
download | rneovim-72300feecfbdd7e313ffb06442d6e80989028ac5.tar.gz rneovim-72300feecfbdd7e313ffb06442d6e80989028ac5.tar.bz2 rneovim-72300feecfbdd7e313ffb06442d6e80989028ac5.zip |
Merge pull request #23864 from folke/nvim_win_set_height
fix(api): dont change curwin for nvim_win_set_height
-rw-r--r-- | src/nvim/api/window.c | 14 | ||||
-rw-r--r-- | test/functional/api/window_spec.lua | 16 |
2 files changed, 18 insertions, 12 deletions
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index abe11e6b72..c021fec220 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); } @@ -214,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); } 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 |