Skip to content

Commit 87594aa

Browse files
authored
fix: allow 0 (unlimited) filesystem_watchers.max_events which is the new default, except for windows at 1000 (#3279)
1 parent e49b0d9 commit 87594aa

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

doc/nvim-tree-lua.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,9 +1709,11 @@ Config: filesystem_watchers *nvim-tree-config-filesystem-watchers*
17091709
between filesystem change and tree update.
17101710
• {ignore_dirs}? (`string[]|(fun(path: string): boolean)`, default: `{ "/.ccls-cache", "/build", "/node_modules", "/target", "/.zig-cache"}`)
17111711
Disable for specific directories.
1712-
• {max_events}? (`integer`, default: `1000`) Disable for a single
1713-
directory after {max_events} consecutive events
1714-
with an interval < {debounce_delay}.
1712+
• {max_events}? (`integer`, default: `0` or `1000` on windows)
1713+
Disable for a single directory after {max_events}
1714+
consecutive events with an interval <
1715+
{debounce_delay}. Set to 0 to allow unlimited
1716+
consecutive events.
17151717

17161718

17171719

@@ -2182,7 +2184,7 @@ Following is the default configuration, see |nvim_tree.config| for details. >lua
21822184
filesystem_watchers = {
21832185
enable = true,
21842186
debounce_delay = 50,
2185-
max_events = 1000,
2187+
max_events = 0,
21862188
ignore_dirs = {
21872189
"/.ccls-cache",
21882190
"/build",

lua/nvim-tree.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ local DEFAULT_OPTS = { -- default-config-start
463463
filesystem_watchers = {
464464
enable = true,
465465
debounce_delay = 50,
466-
max_events = 1000,
466+
max_events = 0,
467467
ignore_dirs = {
468468
"/.ccls-cache",
469469
"/build",
@@ -738,6 +738,9 @@ local function localise_default_opts()
738738
if utils.is_macos or utils.is_windows then
739739
DEFAULT_OPTS.trash.cmd = "trash"
740740
end
741+
if utils.is_windows then
742+
DEFAULT_OPTS.filesystem_watchers.max_events = 1000
743+
end
741744
end
742745

743746
function M.purge_all_state()

lua/nvim-tree/_meta/config/filesystem_watchers.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ error("Cannot require a meta file")
3131
---@field ignore_dirs? string[]|(fun(path: string): boolean)
3232
---
3333
---Disable for a single directory after {max_events} consecutive events with an interval < {debounce_delay}.
34-
---(default: `1000`)
34+
---Set to 0 to allow unlimited consecutive events.
35+
---(default: `0` or `1000` on windows)
3536
---@field max_events? integer

lua/nvim-tree/explorer/watch.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ function M.create_watcher(node)
7979
watcher.data.outstanding_events = watcher.data.outstanding_events + 1
8080

8181
-- disable watcher when outstanding exceeds max
82-
if watcher.data.outstanding_events > M.config.filesystem_watchers.max_events then
82+
if M.config.filesystem_watchers.max_events > 0 and watcher.data.outstanding_events > M.config.filesystem_watchers.max_events then
8383
notify.error(string.format(
8484
"Observed %d consecutive file system events with interval < %dms, exceeding filesystem_watchers.max_events=%s. Disabling watcher for directory '%s'. Consider adding this directory to filesystem_watchers.ignore_dirs",
8585
watcher.data.outstanding_events,
86-
M.config.filesystem_watchers.max_events,
8786
M.config.filesystem_watchers.debounce_delay,
87+
M.config.filesystem_watchers.max_events,
8888
node.absolute_path
8989
))
9090
node:destroy_watcher()

0 commit comments

Comments
 (0)