Skip to content

feat: support ignored path filtering - #114

Closed
shulaoda wants to merge 3 commits into
mainfrom
08-20-feat_support_ignored_path_filtering
Closed

shulaoda wants to merge 3 commits into
mainfrom
08-20-feat_support_ignored_path_filtering

Conversation

@shulaoda

Copy link
Copy Markdown
Member

No description provided.

@shulaoda
shulaoda force-pushed the 08-20-feat_support_ignored_path_filtering branch from ae876ea to 45864c3 Compare August 20, 2026 14:02
@shulaoda
shulaoda force-pushed the 08-20-feat_support_ignored_path_filtering branch from 66dee0c to c086f52 Compare September 21, 2026 02:10
@shulaoda shulaoda closed this Sep 29, 2026
shulaoda added a commit that referenced this pull request Sep 29, 2026
This is a reworked version of #114.

## Why

A watcher cannot skip paths. Watching a project also watches `node_modules` and `.git`, which costs many watch resources and reports events nobody needs. chokidar solves this with `ignored`.

## Changes

Adds `Config::with_ignored(|path, kind| ...)`. An ignored path is treated as if it did not exist:

- It is never watched, scanned or reported. `watch()` and `unwatch()` of it return `Ok(())` and do nothing.
- inotify, kqueue and poll do not descend into ignored directories. FSEvents and Windows watch recursively in the kernel, so they drop the events of ignored paths instead.
- The filter is asked once per path, never about its parents. To ignore a directory with everything inside it, it must return `true` for every path below it.
- `kind` is `Dir`, `File`, or `Unknown` when the watcher cannot tell (a missing path, every event on Windows).
- `notify-debouncer-full` gives the filter to its `FileIdCache` and does not add an ignored path as a root.
- FSEvents restarts its stream only when a watch was really added or removed, because a restart drops events.

## Breaking change

`Config` (and debouncer-mini's `Config`) no longer derive `Copy`, `PartialEq`, `Eq` and `Hash`, because the filter is an `Arc<dyn Fn>`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant