Skip to main content

Module FileWatcherIgnore

Module FileWatcherIgnore 

Source
Expand description

Server-side path ignore filter applied before file-watcher events cross the Mountain→Cocoon IPC boundary. Server-side ignore filter for file-watcher events.

Events that match the ignore list never cross the Mountain→Cocoon gRPC notification boundary. Stops the cargo / pnpm / git-object churn from drowning the editor in dead $fileWatcher:event traffic.

Why server-side: the watcher root + glob pattern coming from extensions (**/*.md, **/package.json, **/*.ts) does not exclude build directories. Even with the per-event glob filter a single cargo check produces thousands of .rcgu.o create / delete events that all match **/*.md’s sibling traversal - every one of them triggers a notification, which Cocoon then tries to stat back through Mountain (returning a 404 because cargo has already deleted the file). One side-effect per call.

The list is deliberately conservative: only paths whose contents are never meaningful to user-facing editor state are excluded. The git work tree (.git/index, .git/HEAD, .git/refs/) is NOT excluded because the Git extension relies on those events to refresh branch / staged-files state.

Override via WatchIgnore env var (colon-separated path segments). Empty value disables the filter entirely. Useful when debugging an extension that legitimately probes inside a Target/ tree.

Constants§

DEFAULT_IGNORE_SEGMENTS 🔒
Default ignore segments. A match anywhere in the path’s component list (case-sensitive) suppresses the event. Tuned against the segments most likely to host high-frequency build churn without containing user-edited source.

Functions§

Fn
true when the path should be silently dropped before any IPC traffic is emitted. Implementation is a single linear scan over the string - tested against git/.git/objects/..., Target/debug/build/.../foo.rcgu.o, and node_modules/.bin/.... Worst case is on every event so we keep this allocation-free.
IgnoreSegments 🔒
Lazily-resolved active ignore list. WatchIgnore overrides the default; an empty string disables filtering entirely.
Path_ContainsSegment 🔒
Match a /seg1/seg2 substring as a complete path segment so target matches /target/... but not /get-target-info/.... Slashes are platform-agnostic - matches both / and \. A needle that itself contains a slash (".git/objects") is matched as a literal substring with leading-slash gating.