mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
fix: only attempt to close timer if not already closing (#26047)
This fixes an error that can occur in certain pathological cases when the autocommand fires at just the right time such that it attempts to close the timer after the timer has already exited, but before the scheduled callback has fired. We now let the timer continue to run even when the autocommand deletes itself to avoid having to repeat the cleanup code multiple times. There is no harm in letting the timer execute if the autocommand does not exist, as the pcall will catch the error.
This commit is contained in:
parent
c37f7bdba5
commit
ba58c6f8a4
@ -254,8 +254,6 @@ do
|
|||||||
callback = function(args)
|
callback = function(args)
|
||||||
if vim.api.nvim_get_option_info2('background', {}).was_set then
|
if vim.api.nvim_get_option_info2('background', {}).was_set then
|
||||||
-- Don't do anything if 'background' is already set
|
-- Don't do anything if 'background' is already set
|
||||||
timer:stop()
|
|
||||||
timer:close()
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -274,9 +272,6 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
timer:stop()
|
|
||||||
timer:close()
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -290,7 +285,10 @@ do
|
|||||||
-- Suppress error if autocommand has already been deleted
|
-- Suppress error if autocommand has already been deleted
|
||||||
pcall(vim.api.nvim_del_autocmd, id)
|
pcall(vim.api.nvim_del_autocmd, id)
|
||||||
end)
|
end)
|
||||||
timer:close()
|
|
||||||
|
if not timer:is_closing() then
|
||||||
|
timer:close()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user