mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Fix #31568
This commit is contained in:
parent
1a6303d5b5
commit
4e94d4ed6a
|
@ -33,19 +33,11 @@
|
|||
},
|
||||
{
|
||||
"fileMatch": "vscode://defaultsettings/settings.json",
|
||||
"url": "vscode://schemas/settings"
|
||||
},
|
||||
{
|
||||
"fileMatch": "vscode://defaultsettings/resourceSettings.json",
|
||||
"url": "vscode://schemas/settings/resource"
|
||||
},
|
||||
{
|
||||
"fileMatch": "vscode://settings/workspaceSettings.json",
|
||||
"url": "vscode://schemas/settings"
|
||||
"url": "vscode://schemas/settings/default"
|
||||
},
|
||||
{
|
||||
"fileMatch": "%APP_SETTINGS_HOME%/settings.json",
|
||||
"url": "vscode://schemas/settings"
|
||||
"url": "vscode://schemas/settings/user"
|
||||
},
|
||||
{
|
||||
"fileMatch": "%APP_WORKSPACES_HOME%/*/workspace.json",
|
||||
|
@ -61,7 +53,7 @@
|
|||
},
|
||||
{
|
||||
"fileMatch": "/.vscode/settings.json",
|
||||
"url": "vscode://schemas/settings"
|
||||
"url": "vscode://schemas/settings/folder"
|
||||
},
|
||||
{
|
||||
"fileMatch": "/.vscode/launch.json",
|
||||
|
|
|
@ -11,6 +11,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
|||
import types = require('vs/base/common/types');
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { IJSONContributionRegistry, Extensions as JSONExtensions } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
|
||||
import { clone } from 'vs/base/common/objects';
|
||||
|
||||
export const Extensions = {
|
||||
Configuration: 'base.contributions.configuration'
|
||||
|
@ -81,33 +82,28 @@ export interface IDefaultConfigurationExtension {
|
|||
defaults: { [key: string]: {} };
|
||||
}
|
||||
|
||||
export const schemaId = 'vscode://schemas/settings';
|
||||
export const settingsSchema: IJSONSchema = { properties: {}, patternProperties: {}, additionalProperties: false, errorMessage: 'Unknown configuration setting' };
|
||||
export const resourceSettingsSchema: IJSONSchema = { properties: {}, patternProperties: {}, additionalProperties: false, errorMessage: 'Unknown configuration setting' };
|
||||
|
||||
export const editorConfigurationSchemaId = 'vscode://schemas/settings/editor';
|
||||
export const resourceConfigurationSchemaId = 'vscode://schemas/settings/resource';
|
||||
const contributionRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
|
||||
|
||||
class ConfigurationRegistry implements IConfigurationRegistry {
|
||||
private configurationContributors: IConfigurationNode[];
|
||||
private configurationProperties: { [qualifiedKey: string]: IJSONSchema };
|
||||
private configurationSchema: IJSONSchema;
|
||||
private editorConfigurationSchema: IJSONSchema;
|
||||
private resourceConfigurationSchema: IJSONSchema;
|
||||
private _onDidRegisterConfiguration: Emitter<IConfigurationRegistry>;
|
||||
private overrideIdentifiers: string[] = [];
|
||||
private overridePropertyPattern: string;
|
||||
|
||||
constructor() {
|
||||
this.configurationContributors = [];
|
||||
this.configurationSchema = { properties: {}, patternProperties: {}, additionalProperties: false, errorMessage: 'Unknown configuration setting' };
|
||||
this.editorConfigurationSchema = { properties: {}, patternProperties: {}, additionalProperties: false, errorMessage: 'Unknown editor configuration setting' };
|
||||
this.resourceConfigurationSchema = { properties: {}, patternProperties: {}, additionalProperties: false, errorMessage: 'Not a resource configuration setting' };
|
||||
this._onDidRegisterConfiguration = new Emitter<IConfigurationRegistry>();
|
||||
this.configurationProperties = {};
|
||||
this.computeOverridePropertyPattern();
|
||||
|
||||
contributionRegistry.registerSchema(schemaId, this.configurationSchema);
|
||||
contributionRegistry.registerSchema(editorConfigurationSchemaId, this.editorConfigurationSchema);
|
||||
contributionRegistry.registerSchema(resourceConfigurationSchemaId, this.resourceConfigurationSchema);
|
||||
}
|
||||
|
||||
public get onDidRegisterConfiguration() {
|
||||
|
@ -208,12 +204,15 @@ class ConfigurationRegistry implements IConfigurationRegistry {
|
|||
}
|
||||
|
||||
private registerJSONConfiguration(configuration: IConfigurationNode) {
|
||||
let configurationSchema = this.configurationSchema;
|
||||
function register(configuration: IConfigurationNode) {
|
||||
let properties = configuration.properties;
|
||||
if (properties) {
|
||||
for (let key in properties) {
|
||||
configurationSchema.properties[key] = properties[key];
|
||||
settingsSchema.properties[key] = properties[key];
|
||||
resourceSettingsSchema.properties[key] = clone(properties[key]);
|
||||
if (properties[key].scope !== ConfigurationScope.RESOURCE) {
|
||||
resourceSettingsSchema.properties[key].doNotSuggest = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
let subNodes = configuration.allOf;
|
||||
|
@ -222,19 +221,17 @@ class ConfigurationRegistry implements IConfigurationRegistry {
|
|||
}
|
||||
};
|
||||
register(configuration);
|
||||
contributionRegistry.registerSchema(schemaId, configurationSchema);
|
||||
}
|
||||
|
||||
private updateSchemaForOverrideSettingsConfiguration(configuration: IConfigurationNode): void {
|
||||
if (configuration.id !== SETTINGS_OVERRRIDE_NODE_ID) {
|
||||
this.update(configuration);
|
||||
contributionRegistry.registerSchema(editorConfigurationSchemaId, this.editorConfigurationSchema);
|
||||
contributionRegistry.registerSchema(resourceConfigurationSchemaId, this.resourceConfigurationSchema);
|
||||
}
|
||||
}
|
||||
|
||||
private updateOverridePropertyPatternKey(): void {
|
||||
let patternProperties: IJSONSchema = this.configurationSchema.patternProperties[this.overridePropertyPattern];
|
||||
let patternProperties: IJSONSchema = settingsSchema.patternProperties[this.overridePropertyPattern];
|
||||
if (!patternProperties) {
|
||||
patternProperties = {
|
||||
type: 'object',
|
||||
|
@ -243,10 +240,11 @@ class ConfigurationRegistry implements IConfigurationRegistry {
|
|||
$ref: editorConfigurationSchemaId
|
||||
};
|
||||
}
|
||||
delete this.configurationSchema.patternProperties[this.overridePropertyPattern];
|
||||
delete settingsSchema.patternProperties[this.overridePropertyPattern];
|
||||
this.computeOverridePropertyPattern();
|
||||
this.configurationSchema.patternProperties[this.overridePropertyPattern] = patternProperties;
|
||||
contributionRegistry.registerSchema(schemaId, this.configurationSchema);
|
||||
|
||||
settingsSchema.patternProperties[this.overridePropertyPattern] = patternProperties;
|
||||
resourceSettingsSchema.patternProperties[this.overridePropertyPattern] = patternProperties;
|
||||
}
|
||||
|
||||
private update(configuration: IConfigurationNode): void {
|
||||
|
@ -256,11 +254,6 @@ class ConfigurationRegistry implements IConfigurationRegistry {
|
|||
if (properties[key].overridable) {
|
||||
this.editorConfigurationSchema.properties[key] = this.getConfigurationProperties()[key];
|
||||
}
|
||||
switch (properties[key].scope) {
|
||||
case ConfigurationScope.RESOURCE:
|
||||
this.resourceConfigurationSchema.properties[key] = this.getConfigurationProperties()[key];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
let subNodes = configuration.allOf;
|
||||
|
|
|
@ -30,7 +30,7 @@ import { ConfigurationService as GlobalConfigurationService } from 'vs/platform/
|
|||
import * as nls from 'vs/nls';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { ExtensionsRegistry, ExtensionMessageCollector } from 'vs/platform/extensions/common/extensionsRegistry';
|
||||
import { IConfigurationNode, IConfigurationRegistry, Extensions, editorConfigurationSchemaId, IDefaultConfigurationExtension, validateProperty, ConfigurationScope, schemaId } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { IConfigurationNode, IConfigurationRegistry, Extensions, editorConfigurationSchemaId, IDefaultConfigurationExtension, validateProperty, ConfigurationScope, settingsSchema, resourceSettingsSchema } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { createHash } from 'crypto';
|
||||
import { getWorkspaceLabel, IWorkspacesService, IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
|
@ -40,6 +40,11 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
|
|||
import product from 'vs/platform/node/product';
|
||||
import pkg from 'vs/platform/node/package';
|
||||
|
||||
const defaultSettingsSchemaId = 'vscode://schemas/settings/default';
|
||||
const userSettingsSchemaId = 'vscode://schemas/settings/user';
|
||||
const workspaceSettingsSchemaId = 'vscode://schemas/settings/workspace';
|
||||
const folderSettingsSchemaId = 'vscode://schemas/settings/folder';
|
||||
|
||||
interface IStat {
|
||||
resource: URI;
|
||||
isDirectory?: boolean;
|
||||
|
@ -243,7 +248,7 @@ contributionRegistry.registerSchema('vscode://schemas/workspaceConfig', {
|
|||
type: 'object',
|
||||
default: {},
|
||||
description: nls.localize('workspaceConfig.settings.description', "Workspace settings"),
|
||||
$ref: schemaId
|
||||
$ref: workspaceSettingsSchemaId
|
||||
},
|
||||
'extensions': {
|
||||
type: 'object',
|
||||
|
@ -284,6 +289,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
|||
|
||||
this.baseConfigurationService = this._register(new GlobalConfigurationService(environmentService));
|
||||
this._register(this.baseConfigurationService.onDidUpdateConfiguration(e => this.onBaseConfigurationChanged(e)));
|
||||
this._register(configurationRegistry.onDidRegisterConfiguration(e => this.registerConfigurationSchemas()));
|
||||
}
|
||||
|
||||
public getWorkspace(): Workspace {
|
||||
|
@ -468,6 +474,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
|||
}
|
||||
|
||||
private initializeConfiguration(trigger: boolean = true): TPromise<any> {
|
||||
this.registerConfigurationSchemas();
|
||||
this.resetCaches();
|
||||
return this.updateConfiguration()
|
||||
.then(() => {
|
||||
|
@ -497,6 +504,22 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
|||
.then(changed => this.updateWorkspaceConfiguration(true) || changed);
|
||||
}
|
||||
|
||||
private registerConfigurationSchemas(): void {
|
||||
if (this.workspace) {
|
||||
|
||||
contributionRegistry.registerSchema(defaultSettingsSchemaId, settingsSchema);
|
||||
contributionRegistry.registerSchema(userSettingsSchemaId, settingsSchema);
|
||||
|
||||
if (WorkbenchState.WORKSPACE === this.getWorkbenchState()) {
|
||||
contributionRegistry.registerSchema(workspaceSettingsSchemaId, settingsSchema);
|
||||
contributionRegistry.registerSchema(folderSettingsSchemaId, resourceSettingsSchema);
|
||||
} else {
|
||||
contributionRegistry.registerSchema(workspaceSettingsSchemaId, settingsSchema);
|
||||
contributionRegistry.registerSchema(folderSettingsSchemaId, settingsSchema);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private onBaseConfigurationChanged({ source, sourceConfig }: IConfigurationServiceEvent): void {
|
||||
if (this.workspace) {
|
||||
if (source === ConfigurationSource.Default) {
|
||||
|
|
Loading…
Reference in a new issue