fix(#1916): suppress EPERM watcher failures on windows (#1919)

This commit is contained in:
Alexander Courtis 2023-01-16 13:00:57 +11:00 committed by GitHub
parent 1f0fc8d6e8
commit 1b13a49f91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -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:

View File

@ -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