From 998ed03e22771e9c782f7c121e0b0816dc9aef78 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Mon, 17 Jul 2017 14:53:42 +0530 Subject: [PATCH] Fix #30838 --- src/vs/editor/standalone/browser/simpleServices.ts | 3 +++ src/vs/platform/workspace/common/workspace.ts | 5 +++++ .../parts/files/browser/views/explorerView.ts | 2 +- .../services/configuration/node/configuration.ts | 11 ++++++++++- src/vs/workbench/test/workbenchTestServices.ts | 5 +++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index 0567042f112..20d73300814 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -521,6 +521,9 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService { private static SCHEME: 'inmemory'; + private readonly _onDidChangeWorkspaceName: Emitter = new Emitter(); + public readonly onDidChangeWorkspaceName: Event = this._onDidChangeWorkspaceName.event; + private readonly _onDidChangeWorkspaceRoots: Emitter = new Emitter(); public readonly onDidChangeWorkspaceRoots: Event = this._onDidChangeWorkspaceRoots.event; diff --git a/src/vs/platform/workspace/common/workspace.ts b/src/vs/platform/workspace/common/workspace.ts index 25c233611ce..843041b3646 100644 --- a/src/vs/platform/workspace/common/workspace.ts +++ b/src/vs/platform/workspace/common/workspace.ts @@ -48,6 +48,11 @@ export interface IWorkspaceContextService { */ saveWorkspace(location: URI): TPromise; + /** + * An event which fires on workspace name changes. + */ + onDidChangeWorkspaceName: Event; + /** * An event which fires on workspace roots change. */ diff --git a/src/vs/workbench/parts/files/browser/views/explorerView.ts b/src/vs/workbench/parts/files/browser/views/explorerView.ts index d2f2bd57cd1..11a7db0f6c1 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerView.ts @@ -135,7 +135,7 @@ export class ExplorerView extends CollapsibleView { const title = workspace.roots.map(root => labels.getPathLabel(root.fsPath, void 0, this.environmentService)).join(); titleSpan.text(this.name).title(title); }; - this.toDispose.push(this.contextService.onDidChangeWorkspaceRoots(() => setHeader())); + this.toDispose.push(this.contextService.onDidChangeWorkspaceName(() => setHeader())); setHeader(); super.renderHeader(container); diff --git a/src/vs/workbench/services/configuration/node/configuration.ts b/src/vs/workbench/services/configuration/node/configuration.ts index fa6787dfb63..986e7c82392 100644 --- a/src/vs/workbench/services/configuration/node/configuration.ts +++ b/src/vs/workbench/services/configuration/node/configuration.ts @@ -174,6 +174,9 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat protected readonly _onDidChangeWorkspaceRoots: Emitter = this._register(new Emitter()); public readonly onDidChangeWorkspaceRoots: Event = this._onDidChangeWorkspaceRoots.event; + protected readonly _onDidChangeWorkspaceName: Emitter = this._register(new Emitter()); + public readonly onDidChangeWorkspaceName: Event = this._onDidChangeWorkspaceName.event; + constructor() { super(); this._configuration = new Configuration(new BaseConfiguration(new ConfigurationModel(), new ConfigurationModel()), new ConfigurationModel(), new StrictResourceMap>(), this.workspace); @@ -392,6 +395,7 @@ export class WorkspaceServiceImpl extends WorkspaceService { } private onWorkspaceSaved(configPath: URI): TPromise { + let workspaceName = this.workspace.name; this.workspaceConfigPath = configPath; // Reset the workspace if current workspace is single folder @@ -403,9 +407,14 @@ export class WorkspaceServiceImpl extends WorkspaceService { // Update workspace configuration path with new path else { this.workspace.configuration = configPath; + this.workspace.name = getWorkspaceLabel(this.environmentService, { id: this.workspace.id, configPath: this.workspace.configuration.fsPath }); } - return this.initialize(); + return this.initialize().then(() => { + if (workspaceName !== this.workspace.name) { + this._onDidChangeWorkspaceName.fire(); + } + }); } private initializeMulitFolderWorkspace(): TPromise { diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 51ca6b1062a..917b1301481 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -70,6 +70,7 @@ export class TestContextService implements IWorkspaceContextService { private id: string; private options: any; + private _onDidChangeWorkspaceName: Emitter; private _onDidChangeWorkspaceRoots: Emitter; constructor(workspace: any = TestWorkspace, options: any = null) { @@ -79,6 +80,10 @@ export class TestContextService implements IWorkspaceContextService { this._onDidChangeWorkspaceRoots = new Emitter(); } + public get onDidChangeWorkspaceName(): Event { + return this._onDidChangeWorkspaceName.event; + } + public get onDidChangeWorkspaceRoots(): Event { return this._onDidChangeWorkspaceRoots.event; } -- GitLab