提交 f965a2c5 编写于 作者: S Sandeep Somavarapu

Fix #43197

上级 10f4d562
......@@ -336,7 +336,13 @@ export function validateProperty(property: string): string {
return null;
}
export function getScopes(keys: string[]): ConfigurationScope[] {
export function getScopes(): { [key: string]: ConfigurationScope } {
const scopes = {};
const configurationProperties = configurationRegistry.getConfigurationProperties();
return keys.map(key => configurationProperties[key].scope);
for (const key of Object.keys(configurationProperties)) {
scopes[key] = configurationProperties[key].scope;
}
scopes['launch'] = ConfigurationScope.RESOURCE;
scopes['task'] = ConfigurationScope.RESOURCE;
return scopes;
}
......@@ -83,7 +83,7 @@ export interface IInitData {
}
export interface IConfigurationInitData extends IConfigurationData {
configurationScopes: ConfigurationScope[];
configurationScopes: { [key: string]: ConfigurationScope };
}
export interface IWorkspaceConfigurationChangeEventData {
......
......@@ -41,14 +41,14 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape {
private readonly _onDidChangeConfiguration = new Emitter<vscode.ConfigurationChangeEvent>();
private readonly _proxy: MainThreadConfigurationShape;
private readonly _extHostWorkspace: ExtHostWorkspace;
private _configurationScopes: Map<string, ConfigurationScope>;
private _configurationScopes: { [key: string]: ConfigurationScope };
private _configuration: Configuration;
constructor(proxy: MainThreadConfigurationShape, extHostWorkspace: ExtHostWorkspace, data: IConfigurationInitData) {
this._proxy = proxy;
this._extHostWorkspace = extHostWorkspace;
this._configuration = Configuration.parse(data);
this._readConfigurationScopes(data.configurationScopes);
this._configurationScopes = data.configurationScopes;
}
get onDidChangeConfiguration(): Event<vscode.ConfigurationChangeEvent> {
......@@ -129,7 +129,7 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape {
}
private _validateConfigurationAccess(key: string, resource: URI, extensionId: string): void {
const scope = this._configurationScopes.get(key);
const scope = this._configurationScopes[key];
const extensionIdText = extensionId ? `[${extensionId}] ` : '';
if (ConfigurationScope.RESOURCE === scope) {
if (resource === void 0) {
......@@ -145,18 +145,6 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape {
}
}
private _readConfigurationScopes(scopes: ConfigurationScope[]): void {
this._configurationScopes = new Map<string, ConfigurationScope>();
if (scopes.length) {
const defaultKeys = this._configuration.keys(this._extHostWorkspace.workspace).default;
if (defaultKeys.length === scopes.length) {
for (let i = 0; i < defaultKeys.length; i++) {
this._configurationScopes.set(defaultKeys[i], scopes[i]);
}
}
}
}
private _toConfigurationChangeEvent(data: IWorkspaceConfigurationChangeEventData): vscode.ConfigurationChangeEvent {
const changedConfiguration = new ConfigurationModel(data.changedConfiguration.contents, data.changedConfiguration.keys, data.changedConfiguration.overrides);
const changedConfigurationByResource: StrictResourceMap<ConfigurationModel> = new StrictResourceMap<ConfigurationModel>();
......
......@@ -358,7 +358,7 @@ export class ExtensionHostProcessWorker {
private _createExtHostInitData(): TPromise<IInitData> {
return TPromise.join<any>([this._telemetryService.getTelemetryInfo(), this._extensionService.getExtensions()]).then(([telemetryInfo, extensionDescriptions]) => {
const configurationData: IConfigurationInitData = { ...this._configurationService.getConfigurationData(), configurationScopes: [] };
const configurationData: IConfigurationInitData = { ...this._configurationService.getConfigurationData(), configurationScopes: {} };
const r: IInitData = {
parentPid: process.pid,
environment: {
......@@ -376,7 +376,7 @@ export class ExtensionHostProcessWorker {
workspace: this._contextService.getWorkbenchState() === WorkbenchState.EMPTY ? null : <IWorkspaceData>this._contextService.getWorkspace(),
extensions: extensionDescriptions,
// Send configurations scopes only in development mode.
configuration: !this._environmentService.isBuilt || this._environmentService.isExtensionDevelopment ? { ...configurationData, configurationScopes: getScopes(this._configurationService.keys().default) } : configurationData,
configuration: !this._environmentService.isBuilt || this._environmentService.isExtensionDevelopment ? { ...configurationData, configurationScopes: getScopes() } : configurationData,
telemetryInfo,
args: this._environmentService.args,
execPath: this._environmentService.execPath,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册