mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 18:06:30 +00:00
fix(api): nvim_open_win respects requested split window size (#35601)
Problem: requested window size passed to nvim_open_win for splits may be ignored by win_split_ins if it decides to forcefully equalize window sizes instead (e.g: in an attempt to make room for the new window). Solution: try to set the size again if it differs from what was requested. Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
This commit is contained in:
@@ -2259,6 +2259,21 @@ describe('API/win', function()
|
||||
)
|
||||
eq(true, eval 'nvim_tabpage_is_valid(g:tp)')
|
||||
end)
|
||||
|
||||
it('respects requested size for large splits', function()
|
||||
command('vsplit')
|
||||
local win = api.nvim_open_win(0, false, { win = -1, split = 'right', width = 38 })
|
||||
eq(38, api.nvim_win_get_width(win))
|
||||
|
||||
-- No zero-sized windows (e.g: from skipping forced equalization in win_split_ins) if
|
||||
-- requesting a chonky window; that could lead to crashes!
|
||||
api.nvim_open_win(0, false, { win = -1, split = 'right', width = 9999 })
|
||||
eq({ 1, 1, 1, 74 }, eval("range(1, winnr('$'))->map({_, nr -> winwidth(nr)})"))
|
||||
|
||||
command('split')
|
||||
win = api.nvim_open_win(0, false, { win = 0, split = 'below', height = 10 })
|
||||
eq(10, api.nvim_win_get_height(win))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('set_config', function()
|
||||
|
Reference in New Issue
Block a user