fix(api): merge split window config only on success

Problem: nvim_win_set_config may merge configs despite failing to configure a
split, and without applying necessary side-effects (like setting style=minimal
options). Plus, autocommands may apply a different config after the merge,
causing side-effects to apply for an outdated config.

Solution: merge configs last, only on success. Include fields only relevant to
splits. Properly set _cmdline_offset for splits.

Maybe better to disallow _cmdline_offset for splits instead, as the pum is
relative to cmdline_row anyway? (I didn't want to change behaviour too much)

Also use expect_unchanged in an unrelated test to quash a warning.
This commit is contained in:
Sean Dewar
2026-03-07 12:12:02 +00:00
parent 65a1709112
commit 137d5ab01d
5 changed files with 71 additions and 21 deletions

View File

@@ -390,6 +390,12 @@ describe('vim.ui_attach', function()
9 bufname( {12: } |
Excommand:call bufadd^( |
]])
-- _cmdline_offset remains set after being turned into a split.
exec_lua(function()
vim.fn.win_execute(_G.win, 'wincmd J')
end)
feed('<Tab>') -- Was a signed int overflow; offset was INT_MAX despite cmdline_win being set.
eq(9, exec_lua('return vim.api.nvim_win_get_config(_G.win)._cmdline_offset'))
-- No crash after _cmdline_offset window is closed #35584.
exec_lua(function()
vim.ui_detach(_G.ns)