提交 01af5079 编写于 作者: B Benjamin Pasero

Show file paths in inactive panes (fixes #29932)

上级 177cff1c
......@@ -20,7 +20,7 @@ import { RunOnceScheduler } from 'vs/base/common/async';
import { isMacintosh } from 'vs/base/common/platform';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { Position, POSITIONS } from 'vs/platform/editor/common/editor';
import { IEditorGroupService, ITabOptions, GroupArrangement, GroupOrientation } from 'vs/workbench/services/group/common/groupService';
import { IEditorGroupService, IEditorTabOptions, GroupArrangement, GroupOrientation } from 'vs/workbench/services/group/common/groupService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
......@@ -115,7 +115,7 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
private layoutVertically: boolean;
private tabOptions: ITabOptions;
private tabOptions: IEditorTabOptions;
private silos: Builder[];
private silosSize: number[];
......@@ -225,7 +225,7 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
this.extensionService.onReady().then(() => this.onExtensionsReady());
}
private updateTabOptions(tabOptions: ITabOptions, refresh?: boolean): void {
private updateTabOptions(tabOptions: IEditorTabOptions, refresh?: boolean): void {
const tabCloseButton = this.tabOptions ? this.tabOptions.tabCloseButton : 'right';
this.tabOptions = tabOptions;
......
......@@ -24,7 +24,7 @@ import { BaseEditor, EditorDescriptor } from 'vs/workbench/browser/parts/editor/
import { IEditorRegistry, Extensions as EditorExtensions, EditorInput, EditorOptions, ConfirmResult, IWorkbenchEditorConfiguration, IEditorDescriptor, TextEditorOptions, SideBySideEditorInput, TextCompareEditorVisible, TEXT_DIFF_EDITOR_ID } from 'vs/workbench/common/editor';
import { EditorGroupsControl, Rochade, IEditorGroupsControl, ProgressState } from 'vs/workbench/browser/parts/editor/editorGroupsControl';
import { WorkbenchProgressService } from 'vs/workbench/services/progress/browser/progressService';
import { IEditorGroupService, GroupOrientation, GroupArrangement, ITabOptions, IMoveOptions } from 'vs/workbench/services/group/common/groupService';
import { IEditorGroupService, GroupOrientation, GroupArrangement, IEditorTabOptions, IMoveOptions } from 'vs/workbench/services/group/common/groupService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IEditorPart } from 'vs/workbench/services/editor/browser/editorService';
import { IPartService } from 'vs/workbench/services/part/common/partService';
......@@ -91,7 +91,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
private editorGroupsControl: IEditorGroupsControl;
private memento: object;
private stacks: EditorStacksModel;
private tabOptions: ITabOptions;
private tabOptions: IEditorTabOptions;
private forceHideTabs: boolean;
private doNotFireTabOptionsChanged: boolean;
private revealIfOpen: boolean;
......@@ -100,7 +100,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
private _onEditorsMoved: Emitter<void>;
private _onEditorOpenFail: Emitter<EditorInput>;
private _onGroupOrientationChanged: Emitter<void>;
private _onTabOptionsChanged: Emitter<ITabOptions>;
private _onTabOptionsChanged: Emitter<IEditorTabOptions>;
private textCompareEditorVisible: IContextKey<boolean>;
......@@ -134,7 +134,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
this._onEditorsMoved = new Emitter<void>();
this._onEditorOpenFail = new Emitter<EditorInput>();
this._onGroupOrientationChanged = new Emitter<void>();
this._onTabOptionsChanged = new Emitter<ITabOptions>();
this._onTabOptionsChanged = new Emitter<IEditorTabOptions>();
this.visibleEditors = [];
......@@ -160,7 +160,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
showIcons: editorConfig.showIcons,
showTabs: editorConfig.showTabs,
tabCloseButton: editorConfig.tabCloseButton,
tabSubtitleStyle: editorConfig.tabSubtitle,
labelFormat: editorConfig.labelFormat,
};
this.revealIfOpen = editorConfig.revealIfOpen;
......@@ -172,7 +172,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
showIcons: false,
showTabs: true,
tabCloseButton: 'right',
tabSubtitleStyle: 'default',
labelFormat: 'default',
};
this.revealIfOpen = false;
......@@ -224,7 +224,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
showIcons: editorConfig.showIcons,
tabCloseButton: editorConfig.tabCloseButton,
showTabs: this.forceHideTabs ? false : editorConfig.showTabs,
tabSubtitleStyle: editorConfig.tabSubtitle,
labelFormat: editorConfig.labelFormat,
};
if (!this.doNotFireTabOptionsChanged && !objects.equals(oldTabOptions, this.tabOptions)) {
......@@ -281,11 +281,11 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
return this._onGroupOrientationChanged.event;
}
public get onTabOptionsChanged(): Event<ITabOptions> {
public get onTabOptionsChanged(): Event<IEditorTabOptions> {
return this._onTabOptionsChanged.event;
}
public getTabOptions(): ITabOptions {
public getTabOptions(): IEditorTabOptions {
return this.tabOptions;
}
......
......@@ -118,7 +118,15 @@ export class NoTabsTitleControl extends TitleControl {
// Editor Label
const resource = toResource(editor, { supportSideBySide: true });
const name = editor.getName() || '';
const description = isActive ? (editor.getDescription() || '') : '';
const labelFormat = this.editorGroupService.getTabOptions().labelFormat;
let description: string;
if (labelFormat === 'default' && !isActive) {
description = ''; // hide description when group is not active and style is 'default'
} else {
description = editor.getDescription(this.getVerbosity(labelFormat)) || '';
}
let title = editor.getTitle(Verbosity.LONG);
if (description === title) {
title = ''; // dont repeat what is already shown
......@@ -134,4 +142,12 @@ export class NoTabsTitleControl extends TitleControl {
// Update Editor Actions Toolbar
this.updateEditorActionsToolbar();
}
private getVerbosity(style: string): Verbosity {
switch (style) {
case 'short': return Verbosity.SHORT;
case 'long': return Verbosity.LONG;
default: return Verbosity.MEDIUM;
}
}
}
\ No newline at end of file
......@@ -340,8 +340,8 @@ export class TabsTitleControl extends TitleControl {
}
private getTabLabels(editors: IEditorInput[]): IEditorInputLabel[] {
const tabSubtitleStyle = this.editorGroupService.getTabOptions().tabSubtitleStyle;
const { verbosity, shortenDuplicates } = this.getSubtitleConfigFlags(tabSubtitleStyle);
const labelFormat = this.editorGroupService.getTabOptions().labelFormat;
const { verbosity, shortenDuplicates } = this.getLabelConfigFlags(labelFormat);
// Build labels and descriptions for each editor
const labels = editors.map(editor => ({
......@@ -428,7 +428,7 @@ export class TabsTitleControl extends TitleControl {
});
}
private getSubtitleConfigFlags(value: string) {
private getLabelConfigFlags(value: string) {
switch (value) {
case 'short':
return { verbosity: Verbosity.SHORT, shortenDuplicates: false };
......
......@@ -807,7 +807,7 @@ export interface IWorkbenchEditorConfiguration {
openPositioning: 'left' | 'right' | 'first' | 'last';
revealIfOpen: boolean;
swipeToNavigate: boolean,
tabSubtitle: 'default' | 'short' | 'medium' | 'long';
labelFormat: 'default' | 'short' | 'medium' | 'long';
}
};
}
......
......@@ -129,22 +129,22 @@ let workbenchProperties: { [path: string]: IJSONSchema; } = {
'description': nls.localize('showEditorTabs', "Controls if opened editors should show in tabs or not."),
'default': true
},
'workbench.editor.tabSubtitle': {
'workbench.editor.labelFormat': {
'type': 'string',
'enum': ['default', 'short', 'medium', 'long'],
'enumDescriptions': [
nls.localize('workbench.editor.tabSubtitle.default', "When two files have the same name, shows the distinguinshing sections of each file's path."),
nls.localize('workbench.editor.tabSubtitle.short', "Always shows the directory which contains the file."),
nls.localize('workbench.editor.tabSubtitle.medium', "Always shows the file's path relative to the workspace root."),
nls.localize('workbench.editor.tabSubtitle.long', "Always shows the file's absolute path.")
nls.localize('workbench.editor.labelFormat.default', "Show the name of the file. When tabs are enabled and two files have the same name in one group the distinguinshing sections of each file's path is added. When tabs are disabled, the path relative to workspace root is shown if the editor is active."),
nls.localize('workbench.editor.labelFormat.short', "Show the name of the file followed by it's directory name."),
nls.localize('workbench.editor.labelFormat.medium', "Show the name of the file followed by it's path relative to the workspace root."),
nls.localize('workbench.editor.labelFormat.long', "Show the name of the file followed by it's absolute path.")
],
'default': 'default',
'description': nls.localize({ comment: ['This is the description for a setting. Values surrounded by parenthesis are not to be translated.'], key: 'tabDescription' },
`Controls the format of the subtitle for an editor tab. Subtitles show up next to the file name depending on this setting and make it easier to understand the location of a file:
`Controls the format of the label for an editor. Changing this setting can for example make it easier to understand the location of a file:
- short: 'parent'
- medium: 'workspace/src/parent'
- long: '/home/user/workspace/src/parent'
- default: '.../parent', when another tab shares the same title`),
- default: '.../parent', when another tab shares the same title, or the relative workspace path if tabs are disabled`),
},
'workbench.editor.tabCloseButton': {
'type': 'string',
......
......@@ -19,12 +19,12 @@ export type GroupOrientation = 'vertical' | 'horizontal';
export const IEditorGroupService = createDecorator<IEditorGroupService>('editorGroupService');
export interface ITabOptions {
export interface IEditorTabOptions {
showTabs?: boolean;
tabCloseButton?: 'left' | 'right' | 'off';
showIcons?: boolean;
previewEditors?: boolean;
tabSubtitleStyle?: 'default' | 'short' | 'medium' | 'long';
labelFormat?: 'default' | 'short' | 'medium' | 'long';
}
export interface IMoveOptions {
......@@ -63,7 +63,7 @@ export interface IEditorGroupService {
/**
* Emitted when tab options changed.
*/
onTabOptionsChanged: Event<ITabOptions>;
onTabOptionsChanged: Event<IEditorTabOptions>;
/**
* Keyboard focus the editor group at the provided position.
......@@ -131,5 +131,5 @@ export interface IEditorGroupService {
/**
* Returns tab options.
*/
getTabOptions(): ITabOptions;
getTabOptions(): IEditorTabOptions;
}
\ No newline at end of file
......@@ -32,7 +32,7 @@ import { ILifecycleService, ShutdownEvent, ShutdownReason, StartupKind, Lifecycl
import { EditorStacksModel } from 'vs/workbench/common/editor/editorStacksModel';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { IEditorGroupService, GroupArrangement, GroupOrientation, ITabOptions, IMoveOptions } from 'vs/workbench/services/group/common/groupService';
import { IEditorGroupService, GroupArrangement, GroupOrientation, IEditorTabOptions, IMoveOptions } from 'vs/workbench/services/group/common/groupService';
import { TextFileService } from 'vs/workbench/services/textfile/common/textFileService';
import { FileOperationEvent, IFileService, IResolveContentOptions, FileOperationError, IFileStat, IResolveFileResult, IImportResult, FileChangesEvent, IResolveFileOptions, IContent, IUpdateContentOptions, IStreamContent } from 'vs/platform/files/common/files';
import { IModelService } from 'vs/editor/common/services/modelService';
......@@ -440,14 +440,14 @@ export class TestEditorGroupService implements IEditorGroupService {
private _onEditorOpenFail: Emitter<IEditorInput>;
private _onEditorsMoved: Emitter<void>;
private _onGroupOrientationChanged: Emitter<void>;
private _onTabOptionsChanged: Emitter<ITabOptions>;
private _onTabOptionsChanged: Emitter<IEditorTabOptions>;
constructor(callback?: (method: string) => void) {
this._onEditorsMoved = new Emitter<void>();
this._onEditorsChanged = new Emitter<void>();
this._onGroupOrientationChanged = new Emitter<void>();
this._onEditorOpenFail = new Emitter<IEditorInput>();
this._onTabOptionsChanged = new Emitter<ITabOptions>();
this._onTabOptionsChanged = new Emitter<IEditorTabOptions>();
let services = new ServiceCollection();
......@@ -483,7 +483,7 @@ export class TestEditorGroupService implements IEditorGroupService {
return this._onGroupOrientationChanged.event;
}
public get onTabOptionsChanged(): Event<ITabOptions> {
public get onTabOptionsChanged(): Event<IEditorTabOptions> {
return this._onTabOptionsChanged.event;
}
......@@ -540,7 +540,7 @@ export class TestEditorGroupService implements IEditorGroupService {
return this.stacksModel;
}
public getTabOptions(): ITabOptions {
public getTabOptions(): IEditorTabOptions {
return {};
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册