Skip to content

Commit 1c64bb2

Browse files
committed
fix(#3198): document filesystem_watchers.max_events
1 parent 744a8ae commit 1c64bb2

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

doc/nvim-tree-lua.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,12 +2511,25 @@ Config: filesystem_watchers *nvim-tree-config-filesystem-watchers*
25112511
This may be useful when a path is not in `.gitignore` or git integration
25122512
is disabled.
25132513

2514+
On runaway consecutive filesystem events for a single directory with an
2515+
interval < |nvim-tree.filesystem_watchers.debounce_delay|:
2516+
• The filesystem watcher will be disabled for that directory.
2517+
• A warning notification will be shown.
2518+
• Consider adding this directory to |filesystem_watchers.ignore_dirs|
2519+
2520+
The runaway threshold is controlled by {max_events} and has been observed
2521+
when running on Windows PowerShell: an infinite number of filesystem
2522+
events were raised and Nvim hangs.
2523+
25142524
Fields: ~
25152525
{enable}? (`boolean`) (default: `true`)
25162526
• {debounce_delay}? (`integer`, default: `50`) Idle milliseconds
25172527
between filesystem change and tree update.
25182528
• {ignore_dirs}? (`string[]|(fun(path: string): boolean)`, default: `{ "/.ccls-cache", "/build", "/node_modules", "/target", }`)
2519-
Disable for directories.
2529+
Disable for specific directories.
2530+
• {max_events}? (`integer`, default: `100`) Disable for a single
2531+
directory after consecutive events with an interval
2532+
< |nvim-tree.filesystem_watchers.debounce_delay|.
25202533

25212534

25222535

@@ -2987,7 +3000,7 @@ Following is the default configuration, see |nvim_tree.config| for details. >lua
29873000
filesystem_watchers = {
29883001
enable = true,
29893002
debounce_delay = 50,
2990-
max_outstanding_events = 100,
3003+
max_events = 100,
29913004
ignore_dirs = {
29923005
"/.ccls-cache",
29933006
"/build",

lua/nvim-tree.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ local DEFAULT_OPTS = { -- default-config-start
462462
filesystem_watchers = {
463463
enable = true,
464464
debounce_delay = 50,
465-
max_outstanding_events = 100,
465+
max_events = 100,
466466
ignore_dirs = {
467467
"/.ccls-cache",
468468
"/build",

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ error("Cannot require a meta file")
1212
--- - A function that is passed an absolute path and returns `true` to disable
1313
---This may be useful when a path is not in `.gitignore` or git integration is disabled.
1414
---
15+
---On runaway consecutive filesystem events for a single directory with an interval < [nvim-tree.filesystem_watchers.debounce_delay]:
16+
---- The filesystem watcher will be disabled for that directory.
17+
---- A warning notification will be shown.
18+
---- Consider adding this directory to [filesystem_watchers.ignore_dirs]
19+
---
20+
---The runaway threshold is controlled by {max_events} and has been observed when running on Windows PowerShell: an infinite number of filesystem events were raised and Nvim hangs.
21+
---
1522
---@class nvim_tree.config.filesystem_watchers
1623
---
1724
---(default: `true`)
@@ -21,6 +28,10 @@ error("Cannot require a meta file")
2128
---(default: `50`)
2229
---@field debounce_delay? integer
2330
---
24-
---Disable for directories.
31+
---Disable for specific directories.
2532
---(default: `{ "/.ccls-cache", "/build", "/node_modules", "/target", }`)
2633
---@field ignore_dirs? string[]|(fun(path: string): boolean)
34+
---
35+
---Disable for a single directory after consecutive events with an interval < [nvim-tree.filesystem_watchers.debounce_delay].
36+
---(default: `100`)
37+
---@field max_events? integer

lua/nvim-tree/explorer/watch.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ function M.create_watcher(node)
7575
watcher.data.outstanding_events = watcher.data.outstanding_events + 1
7676

7777
-- disable watcher when outstanding exceeds max
78-
if watcher.data.outstanding_events > M.config.filesystem_watchers.max_outstanding_events then
78+
if watcher.data.outstanding_events > M.config.filesystem_watchers.max_events then
7979
notify.error(string.format(
8080
"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",
8181
watcher.data.outstanding_events,
82-
M.config.filesystem_watchers.max_outstanding_events,
82+
M.config.filesystem_watchers.max_events,
8383
M.config.filesystem_watchers.debounce_delay,
8484
node.absolute_path
8585
))

0 commit comments

Comments
 (0)