mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 1ec43773e37997841c5af42b33ddb180e9735bf2
This commit is contained in:
@@ -8,7 +8,7 @@ import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { ResourceMap } from 'vs/base/common/map';
|
||||
import { equals } from 'vs/base/common/objects';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Queue, Barrier } from 'vs/base/common/async';
|
||||
import { Queue, Barrier, runWhenIdle } from 'vs/base/common/async';
|
||||
import { IJSONContributionRegistry, Extensions as JSONExtensions } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
|
||||
import { IWorkspaceContextService, Workspace, WorkbenchState, IWorkspaceFolder, toWorkspaceFolders, IWorkspaceFoldersChangeEvent, WorkspaceFolder, toWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import { ConfigurationModel, DefaultConfigurationModel, ConfigurationChangeEvent, AllKeysConfigurationChangeEvent, mergeChanges } from 'vs/platform/configuration/common/configurationModels';
|
||||
@@ -156,7 +156,7 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
|
||||
return false;
|
||||
}
|
||||
|
||||
private doUpdateFolders(foldersToAdd: IWorkspaceFolderCreationData[], foldersToRemove: URI[], index?: number): Promise<void> {
|
||||
private async doUpdateFolders(foldersToAdd: IWorkspaceFolderCreationData[], foldersToRemove: URI[], index?: number): Promise<void> {
|
||||
if (this.getWorkbenchState() !== WorkbenchState.WORKSPACE) {
|
||||
return Promise.resolve(undefined); // we need a workspace to begin with
|
||||
}
|
||||
@@ -192,13 +192,19 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
|
||||
|
||||
const storedFoldersToAdd: IStoredWorkspaceFolder[] = [];
|
||||
|
||||
foldersToAdd.forEach(folderToAdd => {
|
||||
await Promise.all(foldersToAdd.map(async folderToAdd => {
|
||||
const folderURI = folderToAdd.uri;
|
||||
if (this.contains(currentWorkspaceFolderUris, folderURI)) {
|
||||
return; // already existing
|
||||
}
|
||||
try {
|
||||
const result = await this.fileService.resolve(folderURI);
|
||||
if (!result.isDirectory) {
|
||||
return;
|
||||
}
|
||||
} catch (e) { /* Ignore */ }
|
||||
storedFoldersToAdd.push(getStoredWorkspaceFolder(folderURI, folderToAdd.name, workspaceConfigFolder, slashForPath));
|
||||
});
|
||||
}));
|
||||
|
||||
// Apply to array of newStoredFolders
|
||||
if (storedFoldersToAdd.length > 0) {
|
||||
@@ -380,6 +386,15 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
|
||||
if (folderChanges && (folderChanges.added.length || folderChanges.removed.length || folderChanges.changed.length)) {
|
||||
this._onDidChangeWorkspaceFolders.fire(folderChanges);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Not waiting on this validation to unblock start up
|
||||
this.validateWorkspaceFoldersAndReload();
|
||||
}
|
||||
|
||||
if (!this.localUserConfiguration.hasTasksLoaded) {
|
||||
// Reload local user configuration again to load user tasks
|
||||
runWhenIdle(() => this.reloadLocalUserConfiguration().then(configurationModel => this.onLocalUserConfigurationChanged(configurationModel)), 5000);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -531,11 +546,11 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
|
||||
this.triggerConfigurationChange(change, previous, ConfigurationTarget.USER);
|
||||
}
|
||||
|
||||
private onWorkspaceConfigurationChanged(): Promise<void> {
|
||||
private async onWorkspaceConfigurationChanged(): Promise<void> {
|
||||
if (this.workspace && this.workspace.configuration) {
|
||||
const previous = { data: this._configuration.toData(), workspace: this.workspace };
|
||||
const change = this._configuration.compareAndUpdateWorkspaceConfiguration(this.workspaceConfiguration.getConfiguration());
|
||||
let configuredFolders = toWorkspaceFolders(this.workspaceConfiguration.getFolders(), this.workspace.configuration);
|
||||
let configuredFolders = await this.toValidWorkspaceFolders(toWorkspaceFolders(this.workspaceConfiguration.getFolders(), this.workspace.configuration));
|
||||
const changes = this.compareFolders(this.workspace.folders, configuredFolders);
|
||||
if (changes.added.length || changes.removed.length || changes.changed.length) {
|
||||
this.workspace.folders = configuredFolders;
|
||||
@@ -600,6 +615,28 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
|
||||
})]);
|
||||
}
|
||||
|
||||
private async validateWorkspaceFoldersAndReload(): Promise<void> {
|
||||
const validWorkspaceFolders = await this.toValidWorkspaceFolders(this.workspace.folders);
|
||||
const { removed } = this.compareFolders(this.workspace.folders, validWorkspaceFolders);
|
||||
if (removed.length) {
|
||||
return this.onWorkspaceConfigurationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private async toValidWorkspaceFolders(workspaceFolders: WorkspaceFolder[]): Promise<WorkspaceFolder[]> {
|
||||
const validWorkspaceFolders: WorkspaceFolder[] = [];
|
||||
for (const workspaceFolder of workspaceFolders) {
|
||||
try {
|
||||
const result = await this.fileService.resolve(workspaceFolder.uri);
|
||||
if (!result.isDirectory) {
|
||||
continue;
|
||||
}
|
||||
} catch (e) { /* Ignore */ }
|
||||
validWorkspaceFolders.push(workspaceFolder);
|
||||
}
|
||||
return validWorkspaceFolders;
|
||||
}
|
||||
|
||||
private writeConfigurationValue(key: string, value: any, target: ConfigurationTarget, overrides: IConfigurationOverrides | undefined, donotNotifyError: boolean): Promise<void> {
|
||||
if (target === ConfigurationTarget.DEFAULT) {
|
||||
return Promise.reject(new Error('Invalid configuration target'));
|
||||
|
||||
Reference in New Issue
Block a user