From c5b51f5ea5986d8b1111967949baaa74a8a807d7 Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Mon, 27 Apr 2026 14:38:38 +0200 Subject: [PATCH] fix(git): stop fs watcher before closing debounce timer --- lua/git/repo.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/git/repo.lua b/lua/git/repo.lua index 1e3a99c..a4bdc6b 100644 --- a/lua/git/repo.lua +++ b/lua/git/repo.lua @@ -117,12 +117,16 @@ function Repo:start_watcher() end function Repo:stop_watcher() - self.refresh_handle.close() + -- Stop the libuv watcher first so no further fs-events can trigger + -- self:refresh(); only then tear down the debounce handle. The reverse + -- order leaves a window where an in-flight watcher callback would call + -- a closed debounce timer. if self.watcher then self.watcher:stop() self.watcher:close() self.watcher = nil end + self.refresh_handle.close() end ---@param buf integer