Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/vs/workbench/parts/files/browser/explorerViewlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<void> {
Expand Down Expand Up @@ -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
Expand All @@ -118,6 +120,19 @@ export class ExplorerViewlet extends ComposedViewsViewlet {
this.openEditorsVisibleContextKey.set(!this.contextService.hasWorkspace() || (<IFilesConfiguration>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
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/parts/files/browser/views/explorerView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down