Skip to content

Commit 714456b

Browse files
authored
Watcher: allow to fully turn off a watcher for a workspace via files.watcherExclude (microsoft#150951)
1 parent 711c34b commit 714456b

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/vs/platform/files/node/watcher/parcel/parcelWatcher.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cance
1111
import { toErrorMessage } from 'vs/base/common/errorMessage';
1212
import { Emitter } from 'vs/base/common/event';
1313
import { isEqualOrParent, randomPath } from 'vs/base/common/extpath';
14-
import { ParsedPattern, patternsEquals } from 'vs/base/common/glob';
14+
import { GLOBSTAR, ParsedPattern, patternsEquals } from 'vs/base/common/glob';
1515
import { Disposable } from 'vs/base/common/lifecycle';
1616
import { TernarySearchTree } from 'vs/base/common/map';
1717
import { normalizeNFC } from 'vs/base/common/normalization';
@@ -663,12 +663,17 @@ export class ParcelWatcher extends Disposable implements IRecursiveWatcher {
663663

664664
// Only consider requests for watching that are not
665665
// a child of an existing request path to prevent
666-
// duplication.
666+
// duplication. In addition, drop any request where
667+
// everything is excluded (via `**` glob).
667668
//
668669
// However, allow explicit requests to watch folders
669670
// that are symbolic links because the Parcel watcher
670671
// does not allow to recursively watch symbolic links.
671672
for (const request of requests) {
673+
if (request.excludes.includes(GLOBSTAR)) {
674+
continue; // path is ignored entirely (via `**` glob exclude)
675+
}
676+
672677
if (requestTrie.findSubstr(request.path)) {
673678
try {
674679
const realpath = realpathSync(request.path);

src/vs/platform/files/test/node/parcelWatcher.integrationTest.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ import { ltrim } from 'vs/base/common/strings';
2626

2727
class TestParcelWatcher extends ParcelWatcher {
2828

29-
testNormalizePaths(paths: string[]): string[] {
29+
testNormalizePaths(paths: string[], excludes: string[] = []): string[] {
3030

3131
// Work with strings as paths to simplify testing
3232
const requests: IRecursiveWatchRequest[] = paths.map(path => {
33-
return { path, excludes: [], recursive: true };
33+
return { path, excludes, recursive: true };
3434
});
3535

3636
return this.normalizeRequests(requests).map(request => request.path);
@@ -555,6 +555,10 @@ import { ltrim } from 'vs/base/common/strings';
555555
}
556556
});
557557

558+
test('should ignore when everything excluded', () => {
559+
assert.deepStrictEqual(watcher.testNormalizePaths(['/foo/bar', '/bar'], ['**', 'something']), []);
560+
});
561+
558562
test('excludes are converted to absolute paths', () => {
559563

560564
// undefined / empty

0 commit comments

Comments
 (0)