mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 19:06:31 +00:00
fix(lua): highlight.on_yank can close timer in twice #18976
check whether timer is closing in vim.defer_fn before closing
This commit is contained in:
@@ -373,9 +373,13 @@ end
|
||||
function vim.defer_fn(fn, timeout)
|
||||
vim.validate { fn = { fn, 'c', true}; }
|
||||
local timer = vim.loop.new_timer()
|
||||
timer:start(timeout, 0, vim.schedule_wrap(function()
|
||||
timer:stop()
|
||||
timer:close()
|
||||
timer:start(
|
||||
timeout,
|
||||
0,
|
||||
vim.schedule_wrap(function()
|
||||
if not timer:is_closing() then
|
||||
timer:close()
|
||||
end
|
||||
|
||||
fn()
|
||||
end))
|
||||
|
Reference in New Issue
Block a user