fix(window): yeet grid later when closing float in other tabpage #40758

Problem: #40731 may still crash if close_buffer autocmds reinsert the float's
grid. Plus removing the grid (and posting win_close) is unneeded if
win_close_othertab refuses to close the window later, which is possible.

Solution: do the stuff before freeing the window, like win_close.
This commit is contained in:
Sean Dewar
2026-07-16 00:09:54 +01:00
committed by GitHub
parent 5ce9e74f13
commit 1741da8412
2 changed files with 20 additions and 10 deletions

View File

@@ -10526,12 +10526,22 @@ describe('float window', function()
it('no crash when closing a floating window from a non-current tab', function()
local buf = api.nvim_create_buf(false, true)
local win = api.nvim_open_win(buf, false, { relative = 'editor', width = 5, height = 5, row = 0, col = 0 })
exec_lua(function()
local triggered = exec_lua(function()
vim.cmd.tabnew()
vim.api.nvim_win_call(win, vim.cmd.redraw)
local triggered = false
vim.api.nvim_create_autocmd('BufHidden', {
once = true,
buf = buf,
callback = function()
vim.api.nvim_win_call(win, vim.cmd.redraw)
triggered = true
end,
})
vim.api.nvim_win_close(win, true)
return triggered
end)
api.nvim_win_close(win, true)
assert_alive()
eq(true, triggered)
end)
it(':sleep cursor placement #22639', function()