From a2fa9497d02b3530ca7e7ffbb6e1ba6f8bed1874 Mon Sep 17 00:00:00 2001 From: petevdp Date: Fri, 8 May 2020 15:25:12 -0700 Subject: [PATCH] allow the inline diff editor to be centered --- src/vs/workbench/browser/layout.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index e8d196a218b12..ac32addcfeed8 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -44,6 +44,7 @@ import { LineNumbersType } from 'vs/editor/common/config/editorOptions'; import { ActivitybarPart } from 'vs/workbench/browser/parts/activitybar/activitybarPart'; import { URI } from 'vs/base/common/uri'; import { IViewDescriptorService, ViewContainerLocation } from 'vs/workbench/common/views'; +import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; export enum Settings { ACTIVITYBAR_VISIBLE = 'workbench.activityBar.visible', @@ -398,6 +399,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi const newMenubarVisibility = getMenuBarVisibility(this.configurationService, this.environmentService); this.setMenubarVisibility(newMenubarVisibility, !!skipLayout); + // Centered Layout + this.centerEditorLayout(this.state.editor.centered, skipLayout); } private setSideBarPosition(position: Position): void { @@ -1208,9 +1211,18 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi let smartActive = active; const activeEditor = this.editorService.activeEditor; - if (this.configurationService.getValue('workbench.editor.centeredLayoutAutoResize') - && (this.editorGroupService.groups.length > 1 || (activeEditor && activeEditor instanceof SideBySideEditorInput))) { - smartActive = false; // Respect the auto resize setting - do not go into centered layout if there is more than 1 group. + + const isSideBySideLayout = activeEditor + && activeEditor instanceof SideBySideEditorInput + // DiffEditorInput inherits from SideBySideEditorInput but can still be functionally an inline editor. + && (!(activeEditor instanceof DiffEditorInput) || this.configurationService.getValue('diffEditor.renderSideBySide')); + + const isCenteredLayoutAutoResizing = this.configurationService.getValue('workbench.editor.centeredLayoutAutoResize'); + if ( + isCenteredLayoutAutoResizing + && (this.editorGroupService.groups.length > 1 || isSideBySideLayout) + ) { + smartActive = false; } // Enter Centered Editor Layout