From a6d74034f1e77b0863878526b9f6e1db6144477b Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Sat, 23 Apr 2016 11:31:01 +0200 Subject: [PATCH] Extensions cannot get workspace configurations of their own (fixes #5649) --- .../configuration/common/configurationService.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/vs/platform/configuration/common/configurationService.ts b/src/vs/platform/configuration/common/configurationService.ts index ad1b482ffcd..77545ffea7a 100644 --- a/src/vs/platform/configuration/common/configurationService.ts +++ b/src/vs/platform/configuration/common/configurationService.ts @@ -79,7 +79,7 @@ export abstract class ConfigurationService extends EventEmitter implements IConf protected registerListeners(): void { let unbind = this.eventService.addListener(EventType.FILE_CHANGES, (events) => this.handleFileEvents(events)); - let subscription = Registry.as(Extensions.Configuration).onDidRegisterConfiguration(() => this.handleConfigurationChange()); + let subscription = Registry.as(Extensions.Configuration).onDidRegisterConfiguration(() => this.onDidRegisterConfiguration()); this.callOnDispose = () => { unbind(); subscription.dispose(); @@ -195,6 +195,18 @@ export abstract class ConfigurationService extends EventEmitter implements IConf }); } + private onDidRegisterConfiguration(): void { + + // a new configuration was registered (e.g. from an extension) and this means we do have a new set of + // configuration defaults. since we already loaded the merged set of configuration (defaults < global < workspace), + // we want to update the defaults with the new values. So we take our cached config and mix it into the new + // defaults that we got, overwriting any value present. + this.cachedConfig.config = objects.mixin(objects.clone(model.getDefaultValues()), this.cachedConfig.config, true /* overwrite */); + + // emit this as update to listeners + this.emit(ConfigurationServiceEventTypes.UPDATED, { config: this.cachedConfig.config }); + } + protected handleConfigurationChange(): void { if (!this.reloadConfigurationScheduler) { this.reloadConfigurationScheduler = new RunOnceScheduler(() => { -- GitLab