From bae45ef449d8811061cc940459e70e883a3aa83a Mon Sep 17 00:00:00 2001 From: Toby Hutton Date: Wed, 9 Aug 2023 18:08:20 +1000 Subject: [PATCH] fix: accommodate watcher receiving a nil filename. (#851) * fix: accommodate watcher receiving a nil filename. * fix: add a comment for the watcher callback nil filename check. --- lua/gitsigns/watcher.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/gitsigns/watcher.lua b/lua/gitsigns/watcher.lua index 9640f10d..71071b7c 100644 --- a/lua/gitsigns/watcher.lua +++ b/lua/gitsigns/watcher.lua @@ -116,7 +116,10 @@ function M.watch_gitdir(bufnr, gitdir) local info = string.format("Git dir update: '%s' %s", filename, inspect(events)) - if vim.endswith(filename, '.lock') then + -- The luv docs say filename is passed as a string but it has been observed + -- to sometimes be nil. + -- https://github.com/lewis6991/gitsigns.nvim/issues/848 + if filename == nil or vim.endswith(filename, '.lock') then dprintf('%s (ignoring)', info) return end