Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow createFileSystemWatcher with custom exclude rules #169724

Closed
bpasero opened this issue Dec 21, 2022 · 8 comments
Closed

Allow createFileSystemWatcher with custom exclude rules #169724

bpasero opened this issue Dec 21, 2022 · 8 comments
Assignees
Labels
api api-proposal feature-request Request for new features or functionality file-watcher File watcher keep Issues we should not close as out of scope *out-of-scope Posted issue is not in scope of VS Code
Milestone

Comments

@bpasero
Copy link
Member

bpasero commented Dec 21, 2022

Given we make good progress on #137872 we could enrich our file watcher API to allow an extension to provide glob patterns for exclude rules. We can then push these rules down directly to Parcel.

Some things to consider:

@bpasero bpasero added feature-request Request for new features or functionality api file-watcher File watcher keep Issues we should not close as out of scope labels Dec 21, 2022
@bpasero bpasero added this to the Backlog milestone Dec 21, 2022
@mrazauskas
Copy link

Would this allow passing include and exclude to workspace.createFileSystemWatcher just like it works with workspace.findFiles? That would be perfect for wip extension I am currently developing.

To give more detail – the extension is wrapping a testing library, which selects test files using include and exclude globs. The globs are set through a config file (similar to tsconfig.json), hence each folder in a workspace can have different excludes.

Parsing the config file and passing include and exclude to workspace.findFiles works smooth. Also I can create watchers for each folder easily, but un-watching the excludes is cumbersome at the moment.

If I get it right, files.watcherExclude got the necessary upgrade recently. Would be very useful to have this issue fix at some point.

Thanks for the job you do!

@bpasero
Copy link
Member Author

bpasero commented Jan 26, 2023

Yes, I think the idea would be for an extension to have full include and exclude control over recursive and non-recursive watchers.

@eamodio
Copy link
Contributor

eamodio commented Mar 16, 2023

Can't wait for this -- I've tried adding not/exclude patterns in the globPattern that createFileSystemWatcher currently accepts, but they don't seem to work.

@lewisl9029
Copy link

I'd love to see support for an array with multiple exclude globs. This has been a major pain point for me with the current findFiles API which only supports a single glob: #38545

We can sort of hack together some custom logic to combine globs into a single string, but it's super brittle and can fail in unintuitive ways, and doesn't play nicely with the RelativePattern helper.

@bpasero bpasero self-assigned this Oct 10, 2023
@bpasero
Copy link
Member Author

bpasero commented Oct 10, 2023

Proposal:

export interface FileSystemWatcherOptions {
/**
* Ignore when files have been created.
*/
readonly ignoreCreateEvents?: boolean;
/**
* Ignore when files have been changed.
*/
readonly ignoreChangeEvents?: boolean;
/**
* Ignore when files have been deleted.
*/
readonly ignoreDeleteEvents?: boolean;
/**
* An optional set of glob patterns to exclude from watching.
* Glob patterns are always matched relative to the watched folder.
*/
readonly excludes?: string[];
}
export namespace workspace {
export function createFileSystemWatcher(pattern: RelativePattern, options?: FileSystemWatcherOptions): FileSystemWatcher;
}

@Klaim
Copy link

Klaim commented May 30, 2024

Just a note that I confirmed today that #104251 is still not fixed. It was closed as a duplicate of another issue which was also closed but is not enough to fix the issue. This issue (here) seems to be a potential solution so just wanted to make sure that the issue I reported gets tested once this issue is fixed, or at least linked to this one.

Copy link

We closed this issue because we don't plan to address it in the foreseeable future. If you disagree and feel that this issue is crucial: we are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding, and happy coding!

@vs-code-engineering vs-code-engineering bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2024
@bpasero
Copy link
Member Author

bpasero commented Dec 10, 2024

Given our very bad experience with running multiple overlapping file watchers on the same folders, this is unlikely to happen. Quite the opposite, in the future its more likely to have 1 recursive watcher per folder-tree that has no excludes and then implement dispatching from there to anyone interested based on glob patterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api api-proposal feature-request Request for new features or functionality file-watcher File watcher keep Issues we should not close as out of scope *out-of-scope Posted issue is not in scope of VS Code
Projects
None yet
Development

No branches or pull requests

5 participants