提交 4e6ee69a 编写于 作者: S Sandeep Somavarapu

Implement #29831

上级 b6d7f1ca
......@@ -173,7 +173,7 @@ const editorConfiguration: IConfigurationNode = {
'type': 'object',
'title': nls.localize('editorConfigurationTitle', "Editor"),
'overridable': true,
'scope': ConfigurationScope.FOLDER,
'scope': ConfigurationScope.RESOURCE,
'properties': {
'editor.fontFamily': {
'type': 'string',
......
......@@ -53,8 +53,8 @@ export interface IConfigurationRegistry {
}
export enum ConfigurationScope {
WORKSPACE = 1,
FOLDER
WORKBENCH = 1,
RESOURCE
}
export interface IConfigurationPropertySchema extends IJSONSchema {
......@@ -154,7 +154,7 @@ class ConfigurationRegistry implements IConfigurationRegistry {
}
}
private validateAndRegisterProperties(configuration: IConfigurationNode, validate: boolean = true, scope: ConfigurationScope = ConfigurationScope.WORKSPACE, overridable: boolean = false) {
private validateAndRegisterProperties(configuration: IConfigurationNode, validate: boolean = true, scope: ConfigurationScope = ConfigurationScope.WORKBENCH, overridable: boolean = false) {
scope = configuration.scope !== void 0 && configuration.scope !== null ? configuration.scope : scope;
overridable = configuration.overridable || overridable;
let properties = configuration.properties;
......
......@@ -174,7 +174,7 @@ configurationRegistry.registerConfiguration({
'type': 'object',
'description': nls.localize('exclude', "Configure glob patterns for excluding files and folders."),
'default': { '**/.git': true, '**/.svn': true, '**/.hg': true, '**/CVS': true, '**/.DS_Store': true },
'scope': ConfigurationScope.FOLDER,
'scope': ConfigurationScope.RESOURCE,
'additionalProperties': {
'anyOf': [
{
......@@ -204,13 +204,13 @@ configurationRegistry.registerConfiguration({
'enum': Object.keys(SUPPORTED_ENCODINGS),
'default': 'utf8',
'description': nls.localize('encoding', "The default character set encoding to use when reading and writing files."),
'scope': ConfigurationScope.FOLDER
'scope': ConfigurationScope.RESOURCE
},
'files.autoGuessEncoding': {
'type': 'boolean',
'default': false,
'description': nls.localize('autoGuessEncoding', "When enabled, will attempt to guess the character set encoding when opening files"),
'scope': ConfigurationScope.FOLDER
'scope': ConfigurationScope.RESOURCE
},
'files.eol': {
'type': 'string',
......@@ -226,14 +226,14 @@ configurationRegistry.registerConfiguration({
'default': false,
'description': nls.localize('trimTrailingWhitespace', "When enabled, will trim trailing whitespace when saving a file."),
'overridable': true,
'scope': ConfigurationScope.FOLDER
'scope': ConfigurationScope.RESOURCE
},
'files.insertFinalNewline': {
'type': 'boolean',
'default': false,
'description': nls.localize('insertFinalNewline', "When enabled, insert a final new line at the end of the file when saving it."),
'overridable': true,
'scope': ConfigurationScope.FOLDER
'scope': ConfigurationScope.RESOURCE
},
'files.autoSave': {
'type': 'string',
......@@ -256,7 +256,7 @@ configurationRegistry.registerConfiguration({
'type': 'object',
'default': platform.isWindows /* https://github.com/Microsoft/vscode/issues/23954 */ ? { '**/.git/objects/**': true, '**/.git/subtree-cache/**': true, '**/node_modules/*/**': true } : { '**/.git/objects/**': true, '**/.git/subtree-cache/**': true, '**/node_modules/**': true },
'description': nls.localize('watcherExclude', "Configure glob patterns of file paths to exclude from file watching. Patterns must match on absolute paths (i.e. prefix with ** or the full path to match properly). 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."),
'scope': ConfigurationScope.FOLDER
'scope': ConfigurationScope.RESOURCE
},
'files.hotExit': {
'type': 'string',
......
......@@ -363,7 +363,7 @@ configurationRegistry.registerConfiguration({
}
]
},
'scope': ConfigurationScope.FOLDER
'scope': ConfigurationScope.RESOURCE
},
'search.useRipgrep': {
'type': 'boolean',
......
......@@ -129,11 +129,11 @@ export class FolderSettingsModel<T> extends CustomConfigurationModel<T> {
}
public createWorkspaceConfigurationModel(): ConfigurationModel<any> {
return this.createScopedConfigurationModel(ConfigurationScope.WORKSPACE);
return this.createScopedConfigurationModel(ConfigurationScope.WORKBENCH);
}
public createFolderScopedConfigurationModel(): ConfigurationModel<any> {
return this.createScopedConfigurationModel(ConfigurationScope.FOLDER);
return this.createScopedConfigurationModel(ConfigurationScope.RESOURCE);
}
private createScopedConfigurationModel(scope: ConfigurationScope): ConfigurationModel<any> {
......@@ -151,7 +151,7 @@ export class FolderSettingsModel<T> extends CustomConfigurationModel<T> {
private getScope(key: string, configurationProperties: { [qualifiedKey: string]: IConfigurationPropertySchema }): ConfigurationScope {
const propertySchema = configurationProperties[key];
return propertySchema ? propertySchema.scope : ConfigurationScope.WORKSPACE;
return propertySchema ? propertySchema.scope : ConfigurationScope.WORKBENCH;
}
}
......@@ -166,7 +166,7 @@ export class FolderConfigurationModel<T> extends CustomConfigurationModel<T> {
this._contents = <T>{};
this._overrides = [];
this.doMerge(this, ConfigurationScope.WORKSPACE === this.scope ? this.workspaceSettingsConfig : this.workspaceSettingsConfig.createFolderScopedConfigurationModel());
this.doMerge(this, ConfigurationScope.WORKBENCH === this.scope ? this.workspaceSettingsConfig : this.workspaceSettingsConfig.createFolderScopedConfigurationModel());
for (const configModel of this.scopedConfigs) {
this.doMerge(this, configModel);
}
......
......@@ -76,6 +76,11 @@ const configurationExtPoint = ExtensionsRegistry.registerExtensionPoint<IConfigu
properties: {
isExecutable: {
type: 'boolean'
},
scope: {
type: 'string',
enum: ['workbench', 'resource'],
default: 'workbench'
}
}
}
......@@ -147,6 +152,8 @@ function validateProperties(configuration: IConfigurationNode, collector: Extens
}
for (let key in properties) {
const message = validateProperty(key);
const propertyConfiguration = configuration.properties[key];
propertyConfiguration.scope = propertyConfiguration.scope && propertyConfiguration.scope.toString() === 'resource' ? ConfigurationScope.RESOURCE : ConfigurationScope.WORKBENCH;
if (message) {
collector.warn(message);
delete properties[key];
......@@ -485,8 +492,8 @@ export class WorkspaceServiceImpl extends WorkspaceService {
private initCachesForFolders(folders: URI[]): void {
for (const folder of folders) {
this.cachedFolderConfigs.set(folder, this._register(new FolderConfiguration(folder, this.workspaceSettingsRootFolder, this.hasMultiFolderWorkspace() ? ConfigurationScope.FOLDER : ConfigurationScope.WORKSPACE)));
this.updateFolderConfiguration(folder, new FolderConfigurationModel<any>(new FolderSettingsModel<any>(null), [], ConfigurationScope.FOLDER), false);
this.cachedFolderConfigs.set(folder, this._register(new FolderConfiguration(folder, this.workspaceSettingsRootFolder, this.hasMultiFolderWorkspace() ? ConfigurationScope.RESOURCE : ConfigurationScope.WORKBENCH)));
this.updateFolderConfiguration(folder, new FolderConfigurationModel<any>(new FolderSettingsModel<any>(null), [], ConfigurationScope.RESOURCE), false);
}
}
......
......@@ -15,7 +15,7 @@ suite('ConfigurationService - Model', () => {
awesome: true
}));
const testObject = new FolderConfigurationModel(settingsConfig, [], ConfigurationScope.WORKSPACE);
const testObject = new FolderConfigurationModel(settingsConfig, [], ConfigurationScope.WORKBENCH);
assert.equal(testObject.getContentsFor('task'), undefined);
});
......@@ -36,7 +36,7 @@ suite('ConfigurationService - Model', () => {
}
};
assert.deepEqual(new FolderConfigurationModel(settingsConfig, [tasksConfig], ConfigurationScope.WORKSPACE).contents, expected);
assert.deepEqual(new FolderConfigurationModel(settingsConfig, [tasksConfig], ConfigurationScope.WORKBENCH).contents, expected);
});
test('Test consolidate (settings and launch)', () => {
......@@ -55,7 +55,7 @@ suite('ConfigurationService - Model', () => {
}
};
assert.deepEqual(new FolderConfigurationModel(settingsConfig, [launchConfig], ConfigurationScope.WORKSPACE).contents, expected);
assert.deepEqual(new FolderConfigurationModel(settingsConfig, [launchConfig], ConfigurationScope.WORKBENCH).contents, expected);
});
test('Test consolidate (settings and launch and tasks) - launch/tasks wins over settings file', () => {
......@@ -91,7 +91,7 @@ suite('ConfigurationService - Model', () => {
}
};
assert.deepEqual(new FolderConfigurationModel(settingsConfig, [launchConfig, tasksConfig], ConfigurationScope.WORKSPACE).contents, expected);
assert.deepEqual(new FolderConfigurationModel(settingsConfig, [tasksConfig, launchConfig], ConfigurationScope.WORKSPACE).contents, expected);
assert.deepEqual(new FolderConfigurationModel(settingsConfig, [launchConfig, tasksConfig], ConfigurationScope.WORKBENCH).contents, expected);
assert.deepEqual(new FolderConfigurationModel(settingsConfig, [tasksConfig, launchConfig], ConfigurationScope.WORKBENCH).contents, expected);
});
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册