提交 1d149b64 编写于 作者: B Benjamin Pasero

add setting to control icons in editor

上级 85074e41
......@@ -73,7 +73,8 @@ function registerActiveEditorMoveCommand() {
}
function moveActiveEditor(args: ActiveEditorMoveArguments = {}, accessor: ServicesAccessor) {
const tabsShown = !!(<IWorkbenchEditorConfiguration>accessor.get(IConfigurationService).getConfiguration()).workbench.editor.showTabs;
const config = <IWorkbenchEditorConfiguration>accessor.get(IConfigurationService).getConfiguration();
const tabsShown = config.workbench && config.workbench.editor && config.workbench.editor.showTabs;
args.to = args.to || ActiveEditorMovePositioning.RIGHT;
args.by = tabsShown ? args.by || ActiveEditorMovePositioningBy.TAB : ActiveEditorMovePositioningBy.GROUP;
args.value = types.isUndefined(args.value) ? 1 : args.value;
......
......@@ -168,32 +168,42 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
this.extensionService.onReady().then(() => this.onExtensionsReady());
}
private onConfigurationUpdated(configuration: IWorkbenchEditorConfiguration): void {
const useTabs = configuration.workbench.editor.showTabs;
private onConfigurationUpdated(config: IWorkbenchEditorConfiguration): void {
const {showTabs, showIcons} = this.getConfig();
POSITIONS.forEach(position => {
const titleControl = this.getTitleAreaControl(position);
// TItle Container
const titleContainer = $(titleControl.getContainer());
if (useTabs) {
if (showTabs) {
titleContainer.addClass('tabs');
} else {
titleContainer.removeClass('tabs');
}
const showingIcons = titleContainer.hasClass('show-file-icons');
if (showIcons) {
titleContainer.addClass('show-file-icons');
} else {
titleContainer.removeClass('show-file-icons');
}
// Title Control
if (titleControl) {
const usingTabs = (titleControl instanceof TabsTitleControl);
if (usingTabs !== useTabs) {
// Dispose old
// Recreate title when tabs change
if (usingTabs !== showTabs) {
titleControl.dispose();
titleContainer.empty();
// Create new
this.createTitleControl(this.stacks.groupAt(position), this.silos[position], titleContainer, this.getInstantiationService(position));
}
// Refresh title when icons change
else if (showingIcons !== showIcons) {
titleControl.refresh(true);
}
}
});
}
......@@ -765,7 +775,7 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
this.silos[Position.RIGHT] = $(parent).div({ class: 'one-editor-silo editor-right monaco-editor-background' });
// For each position
const useTabs = !!this.configurationService.getConfiguration<IWorkbenchEditorConfiguration>().workbench.editor.showTabs;
const {showTabs, showIcons} = this.getConfig();
POSITIONS.forEach(position => {
const silo = this.silos[position];
......@@ -780,10 +790,12 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
// Title containers
const titleContainer = $(container).div({ 'class': 'title' });
if (useTabs) {
if (showTabs) {
titleContainer.addClass('tabs');
}
titleContainer.addClass('show-file-icons');
if (showIcons)  {
titleContainer.addClass('show-file-icons');
}
this.hookTitleDragListener(titleContainer);
// Title Control
......@@ -980,14 +992,13 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
function createOverlay(target: HTMLElement): void {
if (!overlay) {
const {showTabs} = this.getConfig();
const containers = $this.visibleEditors.filter(e => !!e).map(e => e.getContainer());
containers.forEach((container, index) => {
if (container && DOM.isAncestor(target, container.getHTMLElement())) {
const useTabs = !!$this.configurationService.getConfiguration<IWorkbenchEditorConfiguration>().workbench.editor.showTabs;
overlay = $('div').style({
top: useTabs ? SideBySideEditorControl.EDITOR_TITLE_HEIGHT + 'px' : 0,
height: useTabs ? `calc(100% - ${SideBySideEditorControl.EDITOR_TITLE_HEIGHT}px` : '100%'
top: showTabs ? SideBySideEditorControl.EDITOR_TITLE_HEIGHT + 'px' : 0,
height: showTabs ? `calc(100% - ${SideBySideEditorControl.EDITOR_TITLE_HEIGHT}px` : '100%'
}).id(overlayId);
overlay.appendTo(container);
......@@ -1076,9 +1087,9 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
}
private createTitleControl(context: IEditorGroup, silo: Builder, container: Builder, instantiationService: IInstantiationService): void {
const useTabs = !!this.configurationService.getConfiguration<IWorkbenchEditorConfiguration>().workbench.editor.showTabs;
const {showTabs} = this.getConfig();
const titleAreaControl = instantiationService.createInstance<ITitleAreaControl>(useTabs ? TabsTitleControl : NoTabsTitleControl);
const titleAreaControl = instantiationService.createInstance<ITitleAreaControl>(showTabs ? TabsTitleControl : NoTabsTitleControl);
titleAreaControl.create(container.getHTMLElement());
titleAreaControl.setContext(context);
titleAreaControl.refresh(true /* instant */);
......@@ -1086,6 +1097,14 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
silo.child().setProperty(SideBySideEditorControl.TITLE_AREA_CONTROL_KEY, titleAreaControl); // associate with container
}
private getConfig(config = this.configurationService.getConfiguration<IWorkbenchEditorConfiguration>()): { showTabs?: boolean; showIcons?: boolean } {
if (config.workbench && config.workbench.editor) {
return { showTabs: config.workbench.editor.showTabs, showIcons: config.workbench.editor.showIcons };
}
return Object.create(null);
}
private findPosition(element: HTMLElement): Position {
let parent = element.parentElement;
while (parent) {
......
......@@ -146,8 +146,8 @@ export abstract class TitleControl implements ITitleAreaControl {
}
private onConfigurationUpdated(config: IWorkbenchEditorConfiguration): void {
this.previewEditors = config.workbench.editor.enablePreview;
this.showTabs = config.workbench.editor.showTabs;
this.previewEditors = config.workbench && config.workbench.editor && config.workbench.editor.enablePreview;
this.showTabs = config.workbench && config.workbench.editor && config.workbench.editor.showTabs;
}
private updateSplitActionEnablement(): void {
......
......@@ -880,6 +880,7 @@ export interface IWorkbenchEditorConfiguration {
workbench: {
editor: {
showTabs: boolean;
showIcons: boolean;
enablePreview: boolean;
enablePreviewFromQuickOpen: boolean;
openPositioning: string;
......
......@@ -74,6 +74,11 @@ configurationRegistry.registerConfiguration({
'description': nls.localize('showEditorTabs', "Controls if opened editors should show in tabs or not."),
'default': true
},
'workbench.editor.showIcons': {
'type': 'boolean',
'description': nls.localize('showIcons', "Controls if opened editors should show with an icon or not."),
'default': true
},
'workbench.editor.enablePreview': {
'type': 'boolean',
'description': nls.localize('enablePreview', "Controls if opened editors show as preview. Preview editors are reused until they are kept (e.g. via double click or editing)."),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册