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