提交 45f682c6 编写于 作者: B Benjamin Pasero

Show full path in Title Bar (fixes #12625)

上级 1437e44c
......@@ -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
......@@ -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 ((<EditorInput>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 = [];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册