From d6e34b158d892cd774b36503cbd3a9e62c7951e3 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 19 Oct 2025 12:13:18 +0200 Subject: [PATCH] fix(explorer.watch): handle systems where fs_event doesn't return file names. Closes #2190. Closes #2032 --- lua/snacks/explorer/watch.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/snacks/explorer/watch.lua b/lua/snacks/explorer/watch.lua index 840aa809..05412abf 100644 --- a/lua/snacks/explorer/watch.lua +++ b/lua/snacks/explorer/watch.lua @@ -16,11 +16,12 @@ function M.start(path, cb) end local handle = assert(vim.uv.new_fs_event()) local ok, err = handle:start(path, {}, function(_, file, events) - file = path .. "/" .. file if cb then - cb(file, events) + -- Handle nil filename (FreeBSD kqueue bug where filename may be unavailable) + -- In that case, we just pass the path being watched + cb(file and (path .. "/" .. file) or path, events) else - Tree:refresh(vim.fs.dirname(file)) + Tree:refresh(path) M.refresh() end end)