From 2a3475bb3754ea27886a700997e3d6865df528a8 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Wed, 31 May 2023 14:26:37 +0200 Subject: [PATCH] Fix #182309 (#183925) --- .../browser/configurationService.ts | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/vs/workbench/services/configuration/browser/configurationService.ts b/src/vs/workbench/services/configuration/browser/configurationService.ts index 17579d81bf2..c1ce2769288 100644 --- a/src/vs/workbench/services/configuration/browser/configurationService.ts +++ b/src/vs/workbench/services/configuration/browser/configurationService.ts @@ -365,7 +365,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat const application = await this.reloadApplicationConfiguration(true); const { local, remote } = await this.reloadUserConfiguration(); await this.reloadWorkspaceConfiguration(); - await this.loadConfiguration(application, local, remote); + await this.loadConfiguration(application, local, remote, true); return; } @@ -381,7 +381,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat case ConfigurationTarget.USER: { const { local, remote } = await this.reloadUserConfiguration(); - await this.loadConfiguration(this._configuration.applicationConfiguration, local, remote); + await this.loadConfiguration(this._configuration.applicationConfiguration, local, remote, true); return; } case ConfigurationTarget.USER_LOCAL: @@ -436,8 +436,10 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat async initialize(arg: IAnyWorkspaceIdentifier): Promise { mark('code/willInitWorkspaceService'); + const trigger = this.initialized; + this.initialized = false; const workspace = await this.createWorkspace(arg); - await this.updateWorkspaceAndInitializeConfiguration(workspace); + await this.updateWorkspaceAndInitializeConfiguration(workspace, trigger); this.checkAndMarkWorkspaceComplete(false); mark('code/didInitWorkspaceService'); @@ -529,7 +531,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat } } - private async updateWorkspaceAndInitializeConfiguration(workspace: Workspace): Promise { + private async updateWorkspaceAndInitializeConfiguration(workspace: Workspace, trigger: boolean): Promise { const hasWorkspaceBefore = !!this.workspace; let previousState: WorkbenchState | undefined; let previousWorkspacePath: string | undefined; @@ -544,7 +546,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat this.workspace = workspace; } - await this.initializeConfiguration(); + await this.initializeConfiguration(trigger); // Trigger changes after configuration initialization so that configuration is up to date. if (hasWorkspaceBefore) { @@ -589,7 +591,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat return result; } - private async initializeConfiguration(): Promise { + private async initializeConfiguration(trigger: boolean): Promise { await this.defaultConfiguration.initialize(); const [, application, user] = await Promise.all([ @@ -604,7 +606,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat ]); mark('code/willInitWorkspaceConfiguration'); - await this.loadConfiguration(application, user.local, user.remote); + await this.loadConfiguration(application, user.local, user.remote, trigger); mark('code/didInitWorkspaceConfiguration'); } @@ -670,7 +672,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat return this.onWorkspaceFolderConfigurationChanged(folder); } - private async loadConfiguration(applicationConfigurationModel: ConfigurationModel, userConfigurationModel: ConfigurationModel, remoteUserConfigurationModel: ConfigurationModel): Promise { + private async loadConfiguration(applicationConfigurationModel: ConfigurationModel, userConfigurationModel: ConfigurationModel, remoteUserConfigurationModel: ConfigurationModel, trigger: boolean): Promise { // reset caches this.cachedFolderConfigs = new ResourceMap(); @@ -684,11 +686,11 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat const currentConfiguration = this._configuration; this._configuration = new Configuration(this.defaultConfiguration.configurationModel, this.policyConfiguration.configurationModel, applicationConfigurationModel, userConfigurationModel, remoteUserConfigurationModel, workspaceConfiguration, folderConfigurationModels, new ConfigurationModel(), new ResourceMap(), this.workspace); - if (this.initialized) { + this.initialized = true; + + if (trigger) { const change = this._configuration.compare(currentConfiguration); this.triggerConfigurationChange(change, { data: currentConfiguration.toData(), workspace: this.workspace }, ConfigurationTarget.WORKSPACE); - } else { - this.initialized = true; } this.updateRestrictedSettings(); @@ -722,7 +724,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat } } const [localUser, application] = await Promise.all(promises); - await this.loadConfiguration(application ?? this._configuration.applicationConfiguration, localUser, this._configuration.remoteUserConfiguration); + await this.loadConfiguration(application ?? this._configuration.applicationConfiguration, localUser, this._configuration.remoteUserConfiguration, true); })()); }