From 078041e9d060a386b0c9d3a8c7a7b019a35d3fb0 Mon Sep 17 00:00:00 2001 From: Ivan Pankratov Date: Sun, 17 Mar 2024 12:27:32 +0500 Subject: [PATCH] fix(watcher): improve buffer check in handler --- lua/gitsigns/watcher.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/gitsigns/watcher.lua b/lua/gitsigns/watcher.lua index 37a3b74..fffd5ee 100644 --- a/lua/gitsigns/watcher.lua +++ b/lua/gitsigns/watcher.lua @@ -64,7 +64,12 @@ local handler = debounce_trailing( --- @param bufnr integer async.void(function(bufnr) local __FUNC__ = 'watcher_handler' - buf_check(bufnr) + + -- Avoid cache hit for detached buffer + -- ref: https://github.com/lewis6991/gitsigns.nvim/issues/956 + if not buf_check(bufnr) then + return + end local git_obj = cache[bufnr].git_obj