提交 15cec5d9 编写于 作者: S Sandeep Somavarapu

#47154 Fix Adopt from cached configuration:

Shift to file based configuration only after loading
上级 19b2f873
...@@ -457,21 +457,36 @@ export class FolderConfiguration extends Disposable implements IFolderConfigurat ...@@ -457,21 +457,36 @@ export class FolderConfiguration extends Disposable implements IFolderConfigurat
return this._loaded; return this._loaded;
} }
adopt(fileService: IFileService): boolean { adopt(fileService: IFileService): TPromise<boolean> {
let result = false; if (fileService) {
if (fileService && !(this.folderConfiguration instanceof FileServiceBasedFolderConfiguration)) {
if (this.folderConfiguration instanceof CachedFolderConfiguration) { if (this.folderConfiguration instanceof CachedFolderConfiguration) {
this.folderConfiguration = new FileServiceBasedFolderConfiguration(this.workspaceFolder.uri, this.configFolderRelativePath, this.workbenchState, fileService); return this.adoptFromCachedConfiguration(fileService);
this.updateCache(); }
result = true;
} else { if (this.folderConfiguration instanceof NodeBasedFolderConfiguration) {
const oldFolderConfiguration = this.folderConfiguration; return this.adoptFromNodeBasedConfiguration(fileService);
this.folderConfiguration = new FileServiceBasedFolderConfiguration(this.workspaceFolder.uri, this.configFolderRelativePath, this.workbenchState, fileService, <AbstractFolderConfiguration>oldFolderConfiguration);
oldFolderConfiguration.dispose();
} }
this._register(this.folderConfiguration.onDidChange(e => this.onDidFolderConfigurationChange()));
} }
return result; return TPromise.as(false);
}
private adoptFromCachedConfiguration(fileService: IFileService): TPromise<boolean> {
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<boolean> {
const oldFolderConfiguration = this.folderConfiguration;
this.folderConfiguration = new FileServiceBasedFolderConfiguration(this.workspaceFolder.uri, this.configFolderRelativePath, this.workbenchState, fileService, <AbstractFolderConfiguration>oldFolderConfiguration);
oldFolderConfiguration.dispose();
this._register(this.folderConfiguration.onDidChange(e => this.onDidFolderConfigurationChange()));
return TPromise.as(false);
} }
private onDidFolderConfigurationChange(): void { private onDidFolderConfigurationChange(): void {
......
...@@ -312,14 +312,18 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat ...@@ -312,14 +312,18 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
acquireFileService(fileService: IFileService): void { acquireFileService(fileService: IFileService): void {
this.fileService = fileService; this.fileService = fileService;
const changedWorkspaceFolders: IWorkspaceFolder[] = []; const changedWorkspaceFolders: IWorkspaceFolder[] = [];
this.cachedFolderConfigs.forEach(folderConfiguration => { TPromise.join(this.cachedFolderConfigs.values()
if (folderConfiguration.adopt(fileService)) { .map(folderConfiguration => folderConfiguration.adopt(fileService)
changedWorkspaceFolders.push(folderConfiguration.workspaceFolder); .then(result => {
} if (result) {
}); changedWorkspaceFolders.push(folderConfiguration.workspaceFolder);
for (const workspaceFolder of changedWorkspaceFolders) { }
this.onWorkspaceFolderConfigurationChanged(workspaceFolder); })))
} .then(() => {
for (const workspaceFolder of changedWorkspaceFolders) {
this.onWorkspaceFolderConfigurationChanged(workspaceFolder);
}
});
} }
acquireInstantiationService(instantiationService: IInstantiationService): void { acquireInstantiationService(instantiationService: IInstantiationService): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册