fix(api): nvim_open_win default to half-size for splits (#36088)

Problem: after #35601, nvim_open_win incorrectly attempts to set the size of a
split window to 0 if it wasn't specified.

Solution: only attempt to set the size again if it was actually specified. This has the effect of defaulting to half the size of the parent window (or it may be equalized with other windows to make room), like before.

Fix #36080
This commit is contained in:
Sean Dewar
2025-10-08 17:22:29 +01:00
committed by GitHub
parent c881bc537e
commit d7472c0617
2 changed files with 19 additions and 7 deletions

View File

@@ -2273,6 +2273,16 @@ describe('API/win', function()
command('split')
win = api.nvim_open_win(0, false, { win = 0, split = 'below', height = 10 })
eq(10, api.nvim_win_get_height(win))
-- Still defaults to half-sized when no size was specified.
command('only')
eq(80, api.nvim_win_get_width(0))
api.nvim_open_win(0, true, { split = 'right' })
eq(40, api.nvim_win_get_width(0))
eq(22, api.nvim_win_get_height(0))
api.nvim_open_win(0, true, { split = 'below' })
eq(11, api.nvim_win_get_height(0))
end)
end)