Skip to content

Commit a0f3e99

Browse files
authored
feat(watcher): tear down watcher on failue, warning the user (#1707)
1 parent ed9db63 commit a0f3e99

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lua/nvim-tree/watcher.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ function Event:start()
5454

5555
local event_cb = vim.schedule_wrap(function(err, filename)
5656
if err then
57-
log.line("watcher", "event_cb for %s fail : %s", self._path, err)
57+
log.line("watcher", "event_cb '%s' '%s' FAIL : %s", self._path, filename, err)
58+
self:destroy(string.format("File system watcher failed (%s) for path %s, halting watcher.", err, self._path))
5859
else
5960
log.line("watcher", "event_cb '%s' '%s'", self._path, filename)
6061
for _, listener in ipairs(self._listeners) do
@@ -83,10 +84,14 @@ function Event:remove(listener)
8384
end
8485
end
8586

86-
function Event:destroy()
87+
function Event:destroy(message)
8788
log.line("watcher", "Event:destroy '%s'", self._path)
8889

8990
if self._fs_event then
91+
if message then
92+
utils.notify.warn(message)
93+
end
94+
9095
local rc, _, name = self._fs_event:stop()
9196
if rc ~= 0 then
9297
notify.warn(string.format("Could not stop the fs_event watcher for path %s : %s", self._path, name))

0 commit comments

Comments
 (0)