diff --git a/src/vs/editor/browser/standalone/simpleServices.ts b/src/vs/editor/browser/standalone/simpleServices.ts index 7d6d9ca4fa2..a177a093718 100644 --- a/src/vs/editor/browser/standalone/simpleServices.ts +++ b/src/vs/editor/browser/standalone/simpleServices.ts @@ -516,7 +516,7 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService { } public getWorkspace2(): IWorkspace2 { - return this.workspace ? { id: `${this.id}`, roots: [this.workspace.resource] } : void 0; + return this.workspace ? { id: `${this.id}`, roots: [this.workspace.resource], name: this.workspace.resource.fsPath } : void 0; } public hasWorkspace(): boolean { diff --git a/src/vs/platform/workspace/common/workspace.ts b/src/vs/platform/workspace/common/workspace.ts index b133e6aea4e..7abd76ad14c 100644 --- a/src/vs/platform/workspace/common/workspace.ts +++ b/src/vs/platform/workspace/common/workspace.ts @@ -78,6 +78,11 @@ export interface IWorkspace2 { */ readonly id: string; + /** + * the name of the workspace. + */ + readonly name: string; + /** * Mutliple roots in this workspace. First entry is master and never changes. */ diff --git a/src/vs/workbench/services/configuration/node/configuration.ts b/src/vs/workbench/services/configuration/node/configuration.ts index cb06494acb2..4c62132f61d 100644 --- a/src/vs/workbench/services/configuration/node/configuration.ts +++ b/src/vs/workbench/services/configuration/node/configuration.ts @@ -24,6 +24,8 @@ import { ScopedConfigModel, WorkspaceConfigModel, WorkspaceSettingsConfigModel } import { IConfigurationServiceEvent, ConfigurationSource, getConfigurationValue, IConfigurationOptions, Configuration } from 'vs/platform/configuration/common/configuration'; import { IWorkspaceConfigurationValues, IWorkspaceConfigurationService, IWorkspaceConfigurationValue, WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME, WORKSPACE_STANDALONE_CONFIGURATIONS, WORKSPACE_CONFIG_DEFAULT_PATH } from 'vs/workbench/services/configuration/common/configuration'; import { ConfigurationService as GlobalConfigurationService } from 'vs/platform/configuration/node/configurationService'; +import { createHash } from "crypto"; +import { basename } from "path"; interface IStat { resource: URI; @@ -44,13 +46,31 @@ interface IWorkspaceConfiguration { type IWorkspaceFoldersConfiguration = { [rootFolder: string]: { folders: string[]; } }; class Workspace implements IWorkspace2 { + private _name: string; constructor( public readonly id: string, - public roots: URI[] + private _roots: URI[] ) { // } + + public set roots(roots: URI[]) { + this._roots = roots; + this._name = null; // will be recomputed based on roots next time accessed + } + + public get roots(): URI[] { + return this._roots; + } + + public get name(): string { + if (!this._name) { + this._name = this.roots.map(root => basename(root.fsPath)).join(', '); + } + + return this._name; + } } export class WorkspaceConfigurationService extends Disposable implements IWorkspaceContextService, IWorkspaceConfigurationService { @@ -79,7 +99,7 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp constructor(private environmentService: IEnvironmentService, private singleRootWorkspace?: SingleRootWorkspace, private workspaceSettingsRootFolder: string = WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME) { super(); - this.workspace = singleRootWorkspace ? new Workspace(singleRootWorkspace.resource.toString(), [singleRootWorkspace.resource]) : null; + this.workspace = singleRootWorkspace ? new Workspace(createHash('md5').update(singleRootWorkspace.resource.toString()).digest('hex'), [singleRootWorkspace.resource]) : null; // TODO@Ben for now use the first root folder as id, but revisit this later this.workspaceFilePathToConfiguration = Object.create(null); this.cachedConfig = new Configuration(); diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 372f2d1f494..2ddd8120752 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -94,7 +94,7 @@ export class TestContextService implements IWorkspaceContextService { } public getWorkspace2(): IWorkspace2 { - return this.workspace ? { id: this.id, roots: [this.workspace.resource] } : void 0; + return this.workspace ? { id: this.id, roots: [this.workspace.resource], name: this.workspace.resource.fsPath } : void 0; } public setWorkspace(workspace: any): void {