Watcher: allow to fully turn off a watcher for a workspace via `files.watcherExclude` (#150951)

pull/151401/head
Benjamin Pasero 2022-06-07 09:19:45 +02:00 committed by GitHub
parent 711c34bdb6
commit 714456b9b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -11,7 +11,7 @@ import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cance
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { Emitter } from 'vs/base/common/event';
import { isEqualOrParent, randomPath } from 'vs/base/common/extpath';
import { ParsedPattern, patternsEquals } from 'vs/base/common/glob';
import { GLOBSTAR, ParsedPattern, patternsEquals } from 'vs/base/common/glob';
import { Disposable } from 'vs/base/common/lifecycle';
import { TernarySearchTree } from 'vs/base/common/map';
import { normalizeNFC } from 'vs/base/common/normalization';
@ -663,12 +663,17 @@ export class ParcelWatcher extends Disposable implements IRecursiveWatcher {
// Only consider requests for watching that are not
// a child of an existing request path to prevent
// duplication.
// duplication. In addition, drop any request where
// everything is excluded (via `**` glob).
//
// However, allow explicit requests to watch folders
// that are symbolic links because the Parcel watcher
// does not allow to recursively watch symbolic links.
for (const request of requests) {
if (request.excludes.includes(GLOBSTAR)) {
continue; // path is ignored entirely (via `**` glob exclude)
}
if (requestTrie.findSubstr(request.path)) {
try {
const realpath = realpathSync(request.path);

View File

@ -26,11 +26,11 @@ import { ltrim } from 'vs/base/common/strings';
class TestParcelWatcher extends ParcelWatcher {
testNormalizePaths(paths: string[]): string[] {
testNormalizePaths(paths: string[], excludes: string[] = []): string[] {
// Work with strings as paths to simplify testing
const requests: IRecursiveWatchRequest[] = paths.map(path => {
return { path, excludes: [], recursive: true };
return { path, excludes, recursive: true };
});
return this.normalizeRequests(requests).map(request => request.path);
@ -555,6 +555,10 @@ import { ltrim } from 'vs/base/common/strings';
}
});
test('should ignore when everything excluded', () => {
assert.deepStrictEqual(watcher.testNormalizePaths(['/foo/bar', '/bar'], ['**', 'something']), []);
});
test('excludes are converted to absolute paths', () => {
// undefined / empty