mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
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:
@ -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)
|
||||||
|
Reference in New Issue
Block a user