提交 03467702 编写于 作者: B Benjamin Pasero

introduce files.watcherExclude to be able to configure exclusions for file watching

上级 2b8ba1cd
......@@ -429,6 +429,7 @@ export interface IFilesConfiguration {
files: {
associations: { [filepattern: string]: string };
exclude: glob.IExpression;
watcherExclude: string[];
encoding: string;
trimTrailingWhitespace: boolean;
autoSave: string;
......
......@@ -227,6 +227,14 @@ configurationRegistry.registerConfiguration({
'type': 'number',
'default': 1000,
'description': nls.localize('autoSaveDelay', "Controls the delay in ms after which a dirty file is saved automatically. Only applies when \"files.autoSave\" is set to \"{0}\"", AutoSaveConfiguration.AFTER_DELAY)
},
'files.watcherExclude': {
'type': 'array',
'items': {
'type': 'string'
},
'default': platform.isLinux ? ['**/.git/objects/**', '**/node_modules/**'] : ['**/.git/objects/**'],
'description': nls.localize('watcherExclude', "Configure glob patterns of file paths to exclude from file watching. Changing this setting requires a restart. When you experience Code consuming lots of cpu time on startup, you can exclude large folders to reduce the initial load.")
}
}
});
......
......@@ -7,7 +7,6 @@
import nls = require('vs/nls');
import {TPromise} from 'vs/base/common/winjs.base';
import paths = require('vs/base/common/paths');
import platform = require('vs/base/common/platform');
import encoding = require('vs/base/node/encoding');
import errors = require('vs/base/common/errors');
import strings = require('vs/base/common/strings');
......@@ -44,17 +43,12 @@ export class FileService implements files.IFileService {
encodingOverride.push({ resource: uri.file(paths.join(this.contextService.getWorkspace().resource.fsPath, '.vscode')), encoding: encoding.UTF8 });
}
let doNotWatch = ['**/.git/objects/**']; // this folder does the heavy duty for git and we don't need to watch it
if (platform.isLinux) {
doNotWatch.push('**/node_modules/**'); // Linux does not have a good watching implementation, so we exclude more
}
// build config
let fileServiceConfig: IFileServiceOptions = {
errorLogger: (msg: string) => errors.onUnexpectedError(msg),
encoding: configuration.files && configuration.files.encoding,
encodingOverride: encodingOverride,
watcherIgnoredPatterns: doNotWatch,
watcherIgnoredPatterns: configuration.files && configuration.files.watcherExclude || [],
verboseLogging: this.contextService.getConfiguration().env.verboseLogging
};
......
......@@ -17,7 +17,7 @@ export class FileWatcher {
this.eventEmitter = eventEmitter;
}
public startWatching(): () => void /* dispose */ {
public startWatching(): () => void {
let watcher = new OutOfProcessWin32FolderWatcher(
this.basePath,
this.ignored,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册