提交 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
return this._loaded;
}
adopt(fileService: IFileService): boolean {
let result = false;
if (fileService && !(this.folderConfiguration instanceof FileServiceBasedFolderConfiguration)) {
adopt(fileService: IFileService): TPromise<boolean> {
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, <AbstractFolderConfiguration>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<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 {
......
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册