From cf69a43c086da6db5d93fb4d1a42cf9b278f6a12 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Sun, 21 Jan 2024 23:16:50 +0000 Subject: [PATCH] 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 --- lua/aerial/loading.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/aerial/loading.lua b/lua/aerial/loading.lua index 4c7d29e..ba1eebf 100644 --- a/lua/aerial/loading.lua +++ b/lua/aerial/loading.lua @@ -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