Skip to content

Commit

Permalink
watcher - introduce files.watcherInclude for explicit watching of f…
Browse files Browse the repository at this point in the history
…olders (#132483)
  • Loading branch information
bpasero committed Sep 22, 2021
1 parent 4564730 commit 33c149f
Show file tree
Hide file tree
Showing 14 changed files with 378 additions and 261 deletions.
1 change: 1 addition & 0 deletions src/vs/platform/files/common/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,7 @@ export interface IFilesConfiguration {
associations: { [filepattern: string]: string };
exclude: IExpression;
watcherExclude: { [filepattern: string]: boolean };
watcherInclude: string[];
encoding: string;
autoGuessEncoding: boolean;
defaultLanguage: string;
Expand Down
14 changes: 7 additions & 7 deletions src/vs/platform/files/node/diskFileSystemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { readFileIntoStream } from 'vs/platform/files/common/io';
import { FileWatcher as NodeJSWatcherService } from 'vs/platform/files/node/watcher/nodejs/watcherService';
import { FileWatcher as NsfwWatcherService } from 'vs/platform/files/node/watcher/nsfw/watcherService';
import { FileWatcher as UnixWatcherService } from 'vs/platform/files/node/watcher/unix/watcherService';
import { IDiskFileChange, ILogMessage, toFileChanges } from 'vs/platform/files/node/watcher/watcher';
import { IDiskFileChange, ILogMessage, IWatchRequest, toFileChanges } from 'vs/platform/files/node/watcher/watcher';
import { FileWatcher as WindowsWatcherService } from 'vs/platform/files/node/watcher/win32/watcherService';
import { ILogService, LogLevel } from 'vs/platform/log/common/log';
import product from 'vs/platform/product/common/product';
Expand Down Expand Up @@ -533,23 +533,23 @@ export class DiskFileSystemProvider extends Disposable implements
readonly onDidChangeFile = this._onDidChangeFile.event;

private recursiveWatcher: WindowsWatcherService | UnixWatcherService | NsfwWatcherService | undefined;
private readonly recursiveFoldersToWatch: { path: string, excludes: string[] }[] = [];
private readonly recursiveFoldersToWatch: IWatchRequest[] = [];
private recursiveWatchRequestDelayer = this._register(new ThrottledDelayer<void>(0));

private recursiveWatcherLogLevelListener: IDisposable | undefined;

watch(resource: URI, opts: IWatchOptions): IDisposable {
if (opts.recursive) {
return this.watchRecursive(resource, opts.excludes);
return this.watchRecursive(resource, opts);
}

return this.watchNonRecursive(resource);
}

private watchRecursive(resource: URI, excludes: string[]): IDisposable {
private watchRecursive(resource: URI, opts: IWatchOptions): IDisposable {

// Add to list of folders to watch recursively
const folderToWatch = { path: this.toFilePath(resource), excludes };
const folderToWatch: IWatchRequest = { path: this.toFilePath(resource), excludes: opts.excludes };
const remove = insert(this.recursiveFoldersToWatch, folderToWatch);

// Trigger update
Expand Down Expand Up @@ -578,7 +578,7 @@ export class DiskFileSystemProvider extends Disposable implements

// Reuse existing
if (this.recursiveWatcher instanceof NsfwWatcherService) {
this.recursiveWatcher.setFolders(this.recursiveFoldersToWatch);
this.recursiveWatcher.watch(this.recursiveFoldersToWatch);
}

// Create new
Expand All @@ -592,7 +592,7 @@ export class DiskFileSystemProvider extends Disposable implements
if (this.recursiveFoldersToWatch.length > 0) {
let watcherImpl: {
new(
folders: { path: string, excludes: string[] }[],
folders: IWatchRequest[],
onChange: (changes: IDiskFileChange[]) => void,
onLogMessage: (msg: ILogMessage) => void,
verboseLogging: boolean,
Expand Down
Loading

0 comments on commit 33c149f

Please sign in to comment.