From 45f682c6124eb23912eca48e24911319f0ef97e0 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 2 Nov 2016 08:04:00 +0100 Subject: [PATCH] Show full path in Title Bar (fixes #12625) --- .../electron-browser/main.contribution.ts | 5 +++ .../services/history/browser/history.ts | 33 ++++++++++++++----- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/electron-browser/main.contribution.ts b/src/vs/workbench/electron-browser/main.contribution.ts index afc8ea109be..2dfdca79397 100644 --- a/src/vs/workbench/electron-browser/main.contribution.ts +++ b/src/vs/workbench/electron-browser/main.contribution.ts @@ -151,6 +151,11 @@ configurationRegistry.registerConfiguration({ 'type': 'number', 'default': 0, 'description': nls.localize('zoomLevel', "Adjust the zoom level of the window. The original size is 0 and each increment above (e.g. 1) or below (e.g. -1) represents zooming 20% larger or smaller. You can also enter decimals to adjust the zoom level with a finer granularity.") + }, + 'window.showFullPath': { + 'type': 'boolean', + 'default': false, + 'description': nls.localize('showFullPath', "If enabled, will show the full path of opened files in the window title.") } } }); \ No newline at end of file diff --git a/src/vs/workbench/services/history/browser/history.ts b/src/vs/workbench/services/history/browser/history.ts index 5427b575c82..1a65773bf99 100644 --- a/src/vs/workbench/services/history/browser/history.ts +++ b/src/vs/workbench/services/history/browser/history.ts @@ -9,6 +9,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import errors = require('vs/base/common/errors'); import platform = require('vs/base/common/platform'); import nls = require('vs/nls'); +import labels = require('vs/base/common/labels'); import URI from 'vs/base/common/uri'; import product from 'vs/platform/product'; import { IEditor as IBaseEditor } from 'vs/platform/editor/common/editor'; @@ -26,6 +27,7 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { Registry } from 'vs/platform/platform'; import { once } from 'vs/base/common/event'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; @@ -77,18 +79,21 @@ export abstract class BaseHistoryService { protected toUnbind: IDisposable[]; private activeEditorListeners: IDisposable[]; - private _isPure: boolean; + private isPure: boolean; + + private static NLS_UNSUPPORTED = nls.localize('patchedWindowTitle', "[Unsupported]"); constructor( protected editorGroupService: IEditorGroupService, protected editorService: IWorkbenchEditorService, protected contextService: IWorkspaceContextService, + private configurationService: IConfigurationService, private environmentService: IEnvironmentService, integrityService: IIntegrityService ) { this.toUnbind = []; this.activeEditorListeners = []; - this._isPure = true; + this.isPure = true; // Window Title window.document.title = this.getWindowTitle(null); @@ -96,10 +101,11 @@ export abstract class BaseHistoryService { // Editor Input Changes this.toUnbind.push(this.editorGroupService.onEditorsChanged(() => this.onEditorsChanged())); + // Integrity integrityService.isPure().then((r) => { if (!r.isPure) { - this._isPure = false; - window.document.title = this.getWindowTitle(null); + this.isPure = false; + window.document.title = this.getWindowTitle(this.editorService.getActiveEditorInput()); } }); } @@ -163,8 +169,8 @@ export abstract class BaseHistoryService { protected getWindowTitle(input?: IEditorInput): string { let title = this.doGetWindowTitle(input); - if (!this._isPure) { - title += nls.localize('patchedWindowTitle', " [Unsupported]"); + if (!this.isPure) { + title = `${title} ${BaseHistoryService.NLS_UNSUPPORTED}`; } // Extension Development Host gets a special title to identify itself @@ -176,11 +182,19 @@ export abstract class BaseHistoryService { } private doGetWindowTitle(input?: IEditorInput): string { + const showFullPaths = this.configurationService.lookup('window.showFullPath').value; const appName = product.nameLong; - let prefix = input && input.getName(); + let prefix: string; + const fileInput = asFileEditorInput(input); + if (fileInput && showFullPaths) { + prefix = labels.getPathLabel(fileInput.getResource()); + } else { + prefix = input && input.getName(); + } + if (prefix && input) { - if ((input).isDirty() && !platform.isMacintosh /* Mac has its own decoration in window */) { + if (input.isDirty() && !platform.isMacintosh /* Mac has its own decoration in window */) { prefix = nls.localize('prefixDecoration', "\u25cf {0}", prefix); } } @@ -255,12 +269,13 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic @IEnvironmentService environmentService: IEnvironmentService, @IWorkspaceContextService contextService: IWorkspaceContextService, @IStorageService private storageService: IStorageService, + @IConfigurationService configurationService: IConfigurationService, @ILifecycleService private lifecycleService: ILifecycleService, @IEventService private eventService: IEventService, @IInstantiationService private instantiationService: IInstantiationService, @IIntegrityService integrityService: IIntegrityService ) { - super(editorGroupService, editorService, contextService, environmentService, integrityService); + super(editorGroupService, editorService, contextService, configurationService, environmentService, integrityService); this.index = -1; this.stack = []; -- GitLab