mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-15 18:46:36 -05:00
Merge VS Code 1.31.1 (#4283)
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { dirname } from 'path';
|
||||
import * as assert from 'vs/base/common/assert';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { ResourceMap } from 'vs/base/common/map';
|
||||
@@ -36,7 +35,7 @@ import { massageFolderPathForWorkspace } from 'vs/platform/workspaces/node/works
|
||||
import { UserConfiguration } from 'vs/platform/configuration/node/configuration';
|
||||
import { IJSONSchema, IJSONSchemaMap } from 'vs/base/common/jsonSchema';
|
||||
import { localize } from 'vs/nls';
|
||||
import { isEqual } from 'vs/base/common/resources';
|
||||
import { isEqual, dirname } from 'vs/base/common/resources';
|
||||
import { mark } from 'vs/base/common/performance';
|
||||
|
||||
export class WorkspaceService extends Disposable implements IWorkspaceConfigurationService, IWorkspaceContextService {
|
||||
@@ -44,6 +43,8 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
public _serviceBrand: any;
|
||||
|
||||
private workspace: Workspace;
|
||||
private resolvePromise: Promise<void>;
|
||||
private resolveCallback: () => void;
|
||||
private _configuration: Configuration;
|
||||
private defaultConfiguration: DefaultConfigurationModel;
|
||||
private userConfiguration: UserConfiguration;
|
||||
@@ -52,7 +53,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
|
||||
private workspaceEditingQueue: Queue<void>;
|
||||
|
||||
protected readonly _onDidChangeConfiguration: Emitter<IConfigurationChangeEvent> = this._register(new Emitter<IConfigurationChangeEvent>({ leakWarningThreshold: 500 }));
|
||||
protected readonly _onDidChangeConfiguration: Emitter<IConfigurationChangeEvent> = this._register(new Emitter<IConfigurationChangeEvent>());
|
||||
public readonly onDidChangeConfiguration: Event<IConfigurationChangeEvent> = this._onDidChangeConfiguration.event;
|
||||
|
||||
protected readonly _onDidChangeWorkspaceFolders: Emitter<IWorkspaceFoldersChangeEvent> = this._register(new Emitter<IWorkspaceFoldersChangeEvent>());
|
||||
@@ -71,20 +72,25 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
constructor(private environmentService: IEnvironmentService, private workspaceSettingsRootFolder: string = FOLDER_CONFIG_FOLDER_NAME) {
|
||||
super();
|
||||
|
||||
this.resolvePromise = new Promise(c => this.resolveCallback = c);
|
||||
this.defaultConfiguration = new DefaultConfigurationModel();
|
||||
this.userConfiguration = this._register(new UserConfiguration(environmentService.appSettingsPath));
|
||||
this.workspaceConfiguration = this._register(new WorkspaceConfiguration());
|
||||
this.workspaceConfiguration = this._register(new WorkspaceConfiguration(environmentService));
|
||||
this._register(this.userConfiguration.onDidChangeConfiguration(userConfiguration => this.onUserConfigurationChanged(userConfiguration)));
|
||||
this._register(this.workspaceConfiguration.onDidUpdateConfiguration(() => this.onWorkspaceConfigurationChanged()));
|
||||
|
||||
this._register(Registry.as<IConfigurationRegistry>(Extensions.Configuration).onDidSchemaChange(e => this.registerConfigurationSchemas()));
|
||||
this._register(Registry.as<IConfigurationRegistry>(Extensions.Configuration).onDidRegisterConfiguration(configurationProperties => this.onDefaultConfigurationChanged(configurationProperties)));
|
||||
this._register(Registry.as<IConfigurationRegistry>(Extensions.Configuration).onDidUpdateConfiguration(configurationProperties => this.onDefaultConfigurationChanged(configurationProperties)));
|
||||
|
||||
this.workspaceEditingQueue = new Queue<void>();
|
||||
}
|
||||
|
||||
// Workspace Context Service Impl
|
||||
|
||||
public getCompleteWorkspace(): Promise<Workspace> {
|
||||
return this.resolvePromise.then(() => this.getWorkspace());
|
||||
}
|
||||
|
||||
public getWorkspace(): Workspace {
|
||||
return this.workspace;
|
||||
}
|
||||
@@ -137,11 +143,11 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
|
||||
private doUpdateFolders(foldersToAdd: IWorkspaceFolderCreationData[], foldersToRemove: URI[], index?: number): Promise<void> {
|
||||
if (this.getWorkbenchState() !== WorkbenchState.WORKSPACE) {
|
||||
return Promise.resolve(void 0); // we need a workspace to begin with
|
||||
return Promise.resolve(undefined); // we need a workspace to begin with
|
||||
}
|
||||
|
||||
if (foldersToAdd.length + foldersToRemove.length === 0) {
|
||||
return Promise.resolve(void 0); // nothing to do
|
||||
return Promise.resolve(undefined); // nothing to do
|
||||
}
|
||||
|
||||
let foldersHaveChanged = false;
|
||||
@@ -162,8 +168,8 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
if (foldersToAdd.length) {
|
||||
|
||||
// Recompute current workspace folders if we have folders to add
|
||||
const workspaceConfigFolder = dirname(this.getWorkspace().configuration.fsPath);
|
||||
currentWorkspaceFolders = toWorkspaceFolders(newStoredFolders, URI.file(workspaceConfigFolder));
|
||||
const workspaceConfigFolder = dirname(this.getWorkspace().configuration);
|
||||
currentWorkspaceFolders = toWorkspaceFolders(newStoredFolders, workspaceConfigFolder);
|
||||
const currentWorkspaceFolderUris = currentWorkspaceFolders.map(folder => folder.uri);
|
||||
|
||||
const storedFoldersToAdd: IStoredWorkspaceFolder[] = [];
|
||||
@@ -214,7 +220,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
return this.setFolders(newStoredFolders);
|
||||
}
|
||||
|
||||
return Promise.resolve(void 0);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
private setFolders(folders: IStoredWorkspaceFolder[]): Promise<void> {
|
||||
@@ -245,8 +251,8 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
getValue<T>(overrides: IConfigurationOverrides): T;
|
||||
getValue<T>(section: string, overrides: IConfigurationOverrides): T;
|
||||
getValue(arg1?: any, arg2?: any): any {
|
||||
const section = typeof arg1 === 'string' ? arg1 : void 0;
|
||||
const overrides = isConfigurationOverrides(arg1) ? arg1 : isConfigurationOverrides(arg2) ? arg2 : void 0;
|
||||
const section = typeof arg1 === 'string' ? arg1 : undefined;
|
||||
const overrides = isConfigurationOverrides(arg1) ? arg1 : isConfigurationOverrides(arg2) ? arg2 : undefined;
|
||||
return this._configuration.getValue(section, overrides);
|
||||
}
|
||||
|
||||
@@ -257,7 +263,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
updateValue(key: string, value: any, overrides: IConfigurationOverrides, target: ConfigurationTarget, donotNotifyError: boolean): Promise<void>;
|
||||
updateValue(key: string, value: any, arg3?: any, arg4?: any, donotNotifyError?: any): Promise<void> {
|
||||
assert.ok(this.configurationEditingService, 'Workbench is not initialized yet');
|
||||
const overrides = isConfigurationOverrides(arg3) ? arg3 : void 0;
|
||||
const overrides = isConfigurationOverrides(arg3) ? arg3 : undefined;
|
||||
const target = this.deriveConfigurationTarget(key, value, overrides, overrides ? arg4 : arg3);
|
||||
return target ? this.writeConfigurationValue(key, value, target, overrides, donotNotifyError)
|
||||
: Promise.resolve(null);
|
||||
@@ -303,17 +309,22 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
acquireFileService(fileService: IFileService): void {
|
||||
this.fileService = fileService;
|
||||
const changedWorkspaceFolders: IWorkspaceFolder[] = [];
|
||||
Promise.all(this.cachedFolderConfigs.values()
|
||||
Promise.all([this.workspaceConfiguration.adopt(fileService), ...this.cachedFolderConfigs.values()
|
||||
.map(folderConfiguration => folderConfiguration.adopt(fileService)
|
||||
.then(result => {
|
||||
if (result) {
|
||||
changedWorkspaceFolders.push(folderConfiguration.workspaceFolder);
|
||||
}
|
||||
})))
|
||||
.then(() => {
|
||||
return result;
|
||||
}))])
|
||||
.then(([workspaceChanged]) => {
|
||||
if (workspaceChanged) {
|
||||
this.onWorkspaceConfigurationChanged();
|
||||
}
|
||||
for (const workspaceFolder of changedWorkspaceFolders) {
|
||||
this.onWorkspaceFolderConfigurationChanged(workspaceFolder);
|
||||
}
|
||||
this.resolveCallback();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -335,10 +346,10 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
}
|
||||
|
||||
private createMultiFolderWorkspace(workspaceIdentifier: IWorkspaceIdentifier): Promise<Workspace> {
|
||||
const workspaceConfigPath = URI.file(workspaceIdentifier.configPath);
|
||||
return this.workspaceConfiguration.load(workspaceConfigPath)
|
||||
return this.workspaceConfiguration.load({ id: workspaceIdentifier.id, configPath: URI.file(workspaceIdentifier.configPath) })
|
||||
.then(() => {
|
||||
const workspaceFolders = toWorkspaceFolders(this.workspaceConfiguration.getFolders(), URI.file(dirname(workspaceConfigPath.fsPath)));
|
||||
const workspaceConfigPath = URI.file(workspaceIdentifier.configPath);
|
||||
const workspaceFolders = toWorkspaceFolders(this.workspaceConfiguration.getFolders(), dirname(workspaceConfigPath));
|
||||
const workspaceId = workspaceIdentifier.id;
|
||||
return new Workspace(workspaceId, workspaceFolders, workspaceConfigPath);
|
||||
});
|
||||
@@ -369,7 +380,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
|
||||
if (hasWorkspaceBefore) {
|
||||
previousState = this.getWorkbenchState();
|
||||
previousWorkspacePath = this.workspace.configuration ? this.workspace.configuration.fsPath : void 0;
|
||||
previousWorkspacePath = this.workspace.configuration ? this.workspace.configuration.fsPath : undefined;
|
||||
previousFolders = this.workspace.folders;
|
||||
this.workspace.update(workspace);
|
||||
} else {
|
||||
@@ -387,7 +398,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
this._onDidChangeWorkbenchState.fire(newState);
|
||||
}
|
||||
|
||||
const newWorkspacePath = this.workspace.configuration ? this.workspace.configuration.fsPath : void 0;
|
||||
const newWorkspacePath = this.workspace.configuration ? this.workspace.configuration.fsPath : undefined;
|
||||
if (previousWorkspacePath && newWorkspacePath !== previousWorkspacePath || newState !== previousState) {
|
||||
this._onDidChangeWorkspaceName.fire();
|
||||
}
|
||||
@@ -436,7 +447,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
if (workbenchState === WorkbenchState.WORKSPACE) {
|
||||
return this.workspaceConfiguration.reload().then(() => this.onWorkspaceConfigurationChanged());
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
private reloadWorkspaceFolderConfiguration(folder: IWorkspaceFolder, key?: string): Promise<void> {
|
||||
@@ -531,7 +542,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
private onWorkspaceConfigurationChanged(): Promise<void> {
|
||||
if (this.workspace && this.workspace.configuration && this._configuration) {
|
||||
const workspaceConfigurationChangeEvent = this._configuration.compareAndUpdateWorkspaceConfiguration(this.workspaceConfiguration.getConfiguration());
|
||||
let configuredFolders = toWorkspaceFolders(this.workspaceConfiguration.getFolders(), URI.file(dirname(this.workspace.configuration.fsPath)));
|
||||
let configuredFolders = toWorkspaceFolders(this.workspaceConfiguration.getFolders(), dirname(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;
|
||||
@@ -544,7 +555,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
this.triggerConfigurationChange(workspaceConfigurationChangeEvent, ConfigurationTarget.WORKSPACE);
|
||||
}
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
private onWorkspaceFolderConfigurationChanged(folder: IWorkspaceFolder, key?: string): Promise<void> {
|
||||
@@ -606,7 +617,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
if (target === ConfigurationTarget.MEMORY) {
|
||||
this._configuration.updateValue(key, value, overrides);
|
||||
this.triggerConfigurationChange(new ConfigurationChangeEvent().change(overrides.overrideIdentifier ? [keyFromOverrideIdentifier(overrides.overrideIdentifier)] : [key], overrides.resource), target);
|
||||
return Promise.resolve(null);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
return this.configurationEditingService.writeConfiguration(target, { key, value }, { scopes: overrides, donotNotifyError })
|
||||
@@ -631,22 +642,22 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
|
||||
return target;
|
||||
}
|
||||
|
||||
if (value === void 0) {
|
||||
if (value === undefined) {
|
||||
// Ignore. But expected is to remove the value from all targets
|
||||
return void 0;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const inspect = this.inspect(key, overrides);
|
||||
if (equals(value, inspect.value)) {
|
||||
// No change. So ignore.
|
||||
return void 0;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (inspect.workspaceFolder !== void 0) {
|
||||
if (inspect.workspaceFolder !== undefined) {
|
||||
return ConfigurationTarget.WORKSPACE_FOLDER;
|
||||
}
|
||||
|
||||
if (inspect.workspace !== void 0) {
|
||||
if (inspect.workspace !== undefined) {
|
||||
return ConfigurationTarget.WORKSPACE;
|
||||
}
|
||||
|
||||
@@ -693,8 +704,8 @@ export class DefaultConfigurationExportHelper {
|
||||
|
||||
constructor(
|
||||
@IEnvironmentService environmentService: IEnvironmentService,
|
||||
@IExtensionService private extensionService: IExtensionService,
|
||||
@ICommandService private commandService: ICommandService) {
|
||||
@IExtensionService private readonly extensionService: IExtensionService,
|
||||
@ICommandService private readonly commandService: ICommandService) {
|
||||
if (environmentService.args['export-default-configuration']) {
|
||||
this.writeConfigModelAndQuit(environmentService.args['export-default-configuration']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user