diff --git a/lua/opencode/util.lua b/lua/opencode/util.lua index 304e05b1..3daa540f 100644 --- a/lua/opencode/util.lua +++ b/lua/opencode/util.lua @@ -352,10 +352,10 @@ function M.format_cost(c) end function M.debounce(func, delay) - local timer = nil + local timer ---@type uv.uv_timer_t? return function(...) - if timer then - timer:stop() + if timer and not timer:is_closing() then + timer:close() end local args = { ... } timer = vim.defer_fn(function()