Skip to content

Commit ef8ba5c

Browse files
committed
1 parent 292feda commit ef8ba5c

1 file changed

Lines changed: 27 additions & 15 deletions

File tree

src/vs/workbench/services/configuration/browser/configurationService.ts

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -548,22 +548,34 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
548548

549549
private async onWorkspaceConfigurationChanged(): Promise<void> {
550550
if (this.workspace && this.workspace.configuration) {
551-
const previous = { data: this._configuration.toData(), workspace: this.workspace };
552-
const change = this._configuration.compareAndUpdateWorkspaceConfiguration(this.workspaceConfiguration.getConfiguration());
553-
let configuredFolders = await this.toValidWorkspaceFolders(toWorkspaceFolders(this.workspaceConfiguration.getFolders(), this.workspace.configuration));
554-
const changes = this.compareFolders(this.workspace.folders, configuredFolders);
555-
if (changes.added.length || changes.removed.length || changes.changed.length) {
556-
this.workspace.folders = configuredFolders;
557-
return this.onFoldersChanged()
558-
.then(change => {
559-
this.triggerConfigurationChange(change, previous, ConfigurationTarget.WORKSPACE_FOLDER);
560-
this._onDidChangeWorkspaceFolders.fire(changes);
561-
});
562-
} else {
563-
this.triggerConfigurationChange(change, previous, ConfigurationTarget.WORKSPACE);
551+
let newFolders = toWorkspaceFolders(this.workspaceConfiguration.getFolders(), this.workspace.configuration);
552+
const { added, removed, changed } = this.compareFolders(this.workspace.folders, newFolders);
553+
554+
/* If changed validate new folders */
555+
if (added.length || removed.length || changed.length) {
556+
newFolders = await this.toValidWorkspaceFolders(newFolders);
564557
}
558+
/* Otherwise use existing */
559+
else {
560+
newFolders = this.workspace.folders;
561+
}
562+
563+
await this.updateWorkspaceConfiguration(newFolders, this.workspaceConfiguration.getConfiguration());
564+
}
565+
}
566+
567+
private async updateWorkspaceConfiguration(workspaceFolders: WorkspaceFolder[], configuration: ConfigurationModel): Promise<void> {
568+
const previous = { data: this._configuration.toData(), workspace: this.workspace };
569+
const change = this._configuration.compareAndUpdateWorkspaceConfiguration(configuration);
570+
const changes = this.compareFolders(this.workspace.folders, workspaceFolders);
571+
if (changes.added.length || changes.removed.length || changes.changed.length) {
572+
this.workspace.folders = workspaceFolders;
573+
const change = await this.onFoldersChanged();
574+
this.triggerConfigurationChange(change, previous, ConfigurationTarget.WORKSPACE_FOLDER);
575+
this._onDidChangeWorkspaceFolders.fire(changes);
576+
} else {
577+
this.triggerConfigurationChange(change, previous, ConfigurationTarget.WORKSPACE);
565578
}
566-
return Promise.resolve(undefined);
567579
}
568580

569581
private onWorkspaceFolderConfigurationChanged(folder: IWorkspaceFolder, key?: string): Promise<void> {
@@ -619,7 +631,7 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
619631
const validWorkspaceFolders = await this.toValidWorkspaceFolders(this.workspace.folders);
620632
const { removed } = this.compareFolders(this.workspace.folders, validWorkspaceFolders);
621633
if (removed.length) {
622-
return this.onWorkspaceConfigurationChanged();
634+
await this.updateWorkspaceConfiguration(validWorkspaceFolders, this.workspaceConfiguration.getConfiguration());
623635
}
624636
}
625637

0 commit comments

Comments
 (0)