mirror of
https://github.com/NotAShelf/syntax-gaslighting.nvim.git
synced 2026-04-15 15:33:47 +00:00
rework scheduler to use vim.uv; fall back to vim.loop
This commit is contained in:
parent
398d03c888
commit
a9fea11133
1 changed files with 14 additions and 4 deletions
|
|
@ -191,12 +191,22 @@ end
|
|||
|
||||
--- Debounced update function
|
||||
function M.schedule_update()
|
||||
local uv = vim.uv or vim.loop
|
||||
|
||||
-- Properly clean up the previous timer before creating a new one.
|
||||
-- Do NOT move this block below `uv.new_timer()`, or the new timer
|
||||
-- will be stopped and closed immediately after being created.
|
||||
if timer then
|
||||
timer:stop()
|
||||
timer:close()
|
||||
if timer.stop then timer:stop() end
|
||||
if timer.close then timer:close() end
|
||||
end
|
||||
|
||||
timer = uv.new_timer()
|
||||
|
||||
-- Ensure the new timer is valid before starting it.
|
||||
if timer then
|
||||
timer:start(config.debounce_delay, 0, vim.schedule_wrap(M.update_decorations))
|
||||
end
|
||||
timer = vim.loop.new_timer()
|
||||
timer:start(config.debounce_delay, 0, vim.schedule_wrap(M.update_decorations))
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue