diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index 0567042f112f22f1cb66bf1d4bd61cd05357acb5..20d73300814f8e40622dad8ea2ae116bcfaa3b23 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 25c233611ce9a6ae27ca146d61c936bca5943835..843041b36463dbdc98e67d3040e05a50c5903b5a 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 d2f2bd57cd1dd7725f7e96fbd24bb24ea14e3d45..11a7db0f6c1f882f9986be8c3235840baa544b18 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 fa6787dfb63d98ced8ae2d7afadda042d61d0bd8..986e7c82392b0ff6988eb360c5959da54f16e65a 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 51ca6b1062a0d4c12bfb9f86835fda03bcabec5f..917b13014817803a773eb627db53b93555756fea 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; }