fix: race condition when stopping loading timer (#331)

On Neovim 0.10, calling timer:stop() is not canceling the callback.
There appears to be some minimum amount of buffer time remaining in the
timer in order for it to be able to be canceled correctly. I'm getting
around this by adding a simple guard statement
This commit is contained in:
Steven Arcangeli 2024-01-21 23:16:50 +00:00
parent 8ccc18055b
commit cf69a43c08

View file

@ -20,6 +20,9 @@ M.set_loading = function(aer_bufnr, is_loading)
0,
80,
vim.schedule_wrap(function()
if not timers[aer_bufnr] then
return
end
local lines = { M.spinner_frames[i + 1] .. " Loading" }
util.render_centered_text(aer_bufnr, lines)
i = (i + 1) % #M.spinner_frames