Allow `createFileSystemWatcher` with custom exclude rules
bpasero opened this issue · 6 comments
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:
- we then should probably allow even recursive requests to go through when they are overlapping which we currently block
- if so, we need to revisit #169609
- as for API, we then probably should have another
createFileSystemWatcher
overload acceptingoptions
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!
Yes, I think the idea would be for an extension to have full include
and exclude
control over recursive and non-recursive watchers.
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.
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.
Proposal:
vscode/src/vscode-dts/vscode.proposed.createFileSystemWatcher.d.ts
Lines 10 to 37 in 29b6943