From 468dcd2ddfae539307aeafd9e44bb80894eaa944 Mon Sep 17 00:00:00 2001 From: Dmitry Zabello Date: Tue, 27 Jun 2017 15:48:59 +0300 Subject: [PATCH 1/2] Fixed #29559 Multi root folders view name is not updated on removing root folder --- src/vs/workbench/parts/files/browser/views/explorerView.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/parts/files/browser/views/explorerView.ts b/src/vs/workbench/parts/files/browser/views/explorerView.ts index 4b1e9ddf71632..563798e7f035a 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerView.ts @@ -122,9 +122,9 @@ export class ExplorerView extends CollapsibleView { const titleDiv = $('div.title').appendTo(container); const titleSpan = $('span').appendTo(titleDiv); const setHeader = () => { - const roots = this.contextService.getWorkspace2().roots; - const title = roots.map(root => labels.getPathLabel(root.fsPath, void 0, this.environmentService)).join(); - titleSpan.text(roots.length === 1 ? this.name : nls.localize('folders', "Folders")).title(title); + const workspace = this.contextService.getWorkspace2(); + const title = workspace.roots.map(root => labels.getPathLabel(root.fsPath, void 0, this.environmentService)).join(); + titleSpan.text(workspace.roots.length === 1 ? workspace.name : nls.localize('folders', "Folders")).title(title); }; this.toDispose.push(this.contextService.onDidChangeWorkspaceRoots(() => setHeader())); setHeader(); From 3f876feccc525ba75c085560ef5e95c04250baca Mon Sep 17 00:00:00 2001 From: Dmitry Zabello Date: Wed, 28 Jun 2017 00:29:12 +0300 Subject: [PATCH 2/2] Fixed #29525 Explorer: show "Folders" as title when in multi root --- .../parts/files/browser/explorerViewlet.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/parts/files/browser/explorerViewlet.ts b/src/vs/workbench/parts/files/browser/explorerViewlet.ts index 544b9e59a6596..4fb04714bd4eb 100644 --- a/src/vs/workbench/parts/files/browser/explorerViewlet.ts +++ b/src/vs/workbench/parts/files/browser/explorerViewlet.ts @@ -6,6 +6,7 @@ 'use strict'; import 'vs/css!./media/explorerviewlet'; +import nls = require('vs/nls'); import { IActionRunner } from 'vs/base/common/actions'; import { TPromise } from 'vs/base/common/winjs.base'; import * as DOM from 'vs/base/browser/dom'; @@ -63,6 +64,7 @@ export class ExplorerViewlet extends ComposedViewsViewlet { this.registerViews(); this.onConfigurationUpdated(); this._register(this.configurationService.onDidUpdateConfiguration(e => this.onConfigurationUpdated())); + this._register(this.contextService.onDidChangeWorkspaceRoots(e => this.onWorkspaceRootsChanged())); } public create(parent: Builder): TPromise { @@ -107,7 +109,7 @@ export class ExplorerViewlet extends ComposedViewsViewlet { private createExplorerViewDescriptor(): IViewDescriptor { return { id: ExplorerView.ID, - name: this.contextService.getWorkspace2().name, + name: this.getExplorerCaption(), location: ViewLocation.Explorer, ctor: ExplorerView, order: 1 @@ -118,6 +120,19 @@ export class ExplorerViewlet extends ComposedViewsViewlet { this.openEditorsVisibleContextKey.set(!this.contextService.hasWorkspace() || (this.configurationService.getConfiguration()).explorer.openEditors.visible !== 0); } + private onWorkspaceRootsChanged(): void { + if (this.views.length > 0) { + const name = this.getExplorerCaption(); + this.views.filter(v => v.id === ExplorerView.ID).forEach(v => v.name = name); + this.updateTitleArea(); + } + } + + private getExplorerCaption(): string { + const workspace = this.contextService.getWorkspace2(); + return workspace.roots.length === 1 ? workspace.name : nls.localize('folders', "Folders"); + } + protected createView(viewDescriptor: IViewDescriptor, options: IViewletViewOptions): IView { if (viewDescriptor.id === ExplorerView.ID) { // Create a delegating editor service for the explorer to be able to delay the refresh in the opened