fix(extui): check if buffers/windows exist before deleting (#34886)

Problem: Disabling vim._extui may try to delete non-existent windows/buffers.
Solution: Check that window/buffer is valid before deleting.
This commit is contained in:
Tomasz N
2025-07-11 17:31:30 +02:00
committed by GitHub
parent 4f3aa7bafb
commit 9e968635ef

View File

@ -65,10 +65,14 @@ function M.enable(opts)
if ext.cfg.enable == false then if ext.cfg.enable == false then
-- Detach and cleanup windows, buffers and autocommands. -- Detach and cleanup windows, buffers and autocommands.
for _, win in pairs(ext.wins) do for _, win in pairs(ext.wins) do
api.nvim_win_close(win, true) if api.nvim_win_is_valid(win) then
api.nvim_win_close(win, true)
end
end end
for _, buf in pairs(ext.bufs) do for _, buf in pairs(ext.bufs) do
api.nvim_buf_delete(buf, {}) if api.nvim_buf_is_valid(buf) then
api.nvim_buf_delete(buf, {})
end
end end
api.nvim_clear_autocmds({ group = ext.augroup }) api.nvim_clear_autocmds({ group = ext.augroup })
vim.ui_detach(ext.ns) vim.ui_detach(ext.ns)