From 1b13a49f913b58a5f1792ea81c13947a7988db8e Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Mon, 16 Jan 2023 13:00:57 +1100 Subject: [PATCH] fix(#1916): suppress EPERM watcher failures on windows (#1919) --- doc/nvim-tree-lua.txt | 1 + lua/nvim-tree/watcher.lua | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 4dcd6e7c..f5b96a50 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -1724,5 +1724,6 @@ Windows WSL and PowerShell - Trash is unavailable - Executable file detection is disabled as this is non-performant and can freeze nvim +- Some filesystem watcher error related to permissions will not be reported vim:tw=78:ts=4:sw=4:et:ft=help:norl: diff --git a/lua/nvim-tree/watcher.lua b/lua/nvim-tree/watcher.lua index 97f3a52b..26f463eb 100644 --- a/lua/nvim-tree/watcher.lua +++ b/lua/nvim-tree/watcher.lua @@ -54,7 +54,14 @@ function Event:start() local event_cb = vim.schedule_wrap(function(err, filename) if err then log.line("watcher", "event_cb '%s' '%s' FAIL : %s", self._path, filename, err) - self:destroy(string.format("File system watcher failed (%s) for path %s, halting watcher.", err, self._path)) + local message = string.format("File system watcher failed (%s) for path %s, halting watcher.", err, self._path) + if err == "EPERM" and (utils.is_windows or utils.is_wsl) then + -- on directory removal windows will cascade the filesystem events out of order + log.line("watcher", message) + self:destroy() + else + self:destroy(message) + end else log.line("watcher", "event_cb '%s' '%s'", self._path, filename) for _, listener in ipairs(self._listeners) do