diff --git a/src/vs/workbench/services/configuration/node/configuration.ts b/src/vs/workbench/services/configuration/node/configuration.ts index ee01a17a931f231ebc0fc9c0142bdb6686ba22f3..d34e9369de083f9980fde368f68d499c519bba2e 100644 --- a/src/vs/workbench/services/configuration/node/configuration.ts +++ b/src/vs/workbench/services/configuration/node/configuration.ts @@ -457,21 +457,36 @@ export class FolderConfiguration extends Disposable implements IFolderConfigurat return this._loaded; } - adopt(fileService: IFileService): boolean { - let result = false; - if (fileService && !(this.folderConfiguration instanceof FileServiceBasedFolderConfiguration)) { + adopt(fileService: IFileService): TPromise { + if (fileService) { if (this.folderConfiguration instanceof CachedFolderConfiguration) { - this.folderConfiguration = new FileServiceBasedFolderConfiguration(this.workspaceFolder.uri, this.configFolderRelativePath, this.workbenchState, fileService); - this.updateCache(); - result = true; - } else { - const oldFolderConfiguration = this.folderConfiguration; - this.folderConfiguration = new FileServiceBasedFolderConfiguration(this.workspaceFolder.uri, this.configFolderRelativePath, this.workbenchState, fileService, oldFolderConfiguration); - oldFolderConfiguration.dispose(); + return this.adoptFromCachedConfiguration(fileService); + } + + if (this.folderConfiguration instanceof NodeBasedFolderConfiguration) { + return this.adoptFromNodeBasedConfiguration(fileService); } - this._register(this.folderConfiguration.onDidChange(e => this.onDidFolderConfigurationChange())); } - return result; + return TPromise.as(false); + } + + private adoptFromCachedConfiguration(fileService: IFileService): TPromise { + const folderConfiguration = new FileServiceBasedFolderConfiguration(this.workspaceFolder.uri, this.configFolderRelativePath, this.workbenchState, fileService); + return folderConfiguration.loadConfiguration() + .then(() => { + this.folderConfiguration = folderConfiguration; + this._register(this.folderConfiguration.onDidChange(e => this.onDidFolderConfigurationChange())); + this.updateCache(); + return true; + }); + } + + private adoptFromNodeBasedConfiguration(fileService: IFileService): TPromise { + const oldFolderConfiguration = this.folderConfiguration; + this.folderConfiguration = new FileServiceBasedFolderConfiguration(this.workspaceFolder.uri, this.configFolderRelativePath, this.workbenchState, fileService, oldFolderConfiguration); + oldFolderConfiguration.dispose(); + this._register(this.folderConfiguration.onDidChange(e => this.onDidFolderConfigurationChange())); + return TPromise.as(false); } private onDidFolderConfigurationChange(): void { diff --git a/src/vs/workbench/services/configuration/node/configurationService.ts b/src/vs/workbench/services/configuration/node/configurationService.ts index b2dde23bb54022cd900f7d67cc235315a3bc3e78..fbd6fea2cf6d98a336385ae31066341ff6c0943a 100644 --- a/src/vs/workbench/services/configuration/node/configurationService.ts +++ b/src/vs/workbench/services/configuration/node/configurationService.ts @@ -312,14 +312,18 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat acquireFileService(fileService: IFileService): void { this.fileService = fileService; const changedWorkspaceFolders: IWorkspaceFolder[] = []; - this.cachedFolderConfigs.forEach(folderConfiguration => { - if (folderConfiguration.adopt(fileService)) { - changedWorkspaceFolders.push(folderConfiguration.workspaceFolder); - } - }); - for (const workspaceFolder of changedWorkspaceFolders) { - this.onWorkspaceFolderConfigurationChanged(workspaceFolder); - } + TPromise.join(this.cachedFolderConfigs.values() + .map(folderConfiguration => folderConfiguration.adopt(fileService) + .then(result => { + if (result) { + changedWorkspaceFolders.push(folderConfiguration.workspaceFolder); + } + }))) + .then(() => { + for (const workspaceFolder of changedWorkspaceFolders) { + this.onWorkspaceFolderConfigurationChanged(workspaceFolder); + } + }); } acquireInstantiationService(instantiationService: IInstantiationService): void {