mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-27 19:00:29 +01:00
multi root: workspace name
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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<T> {
|
||||
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<any>();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user