diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index 3c9343f4166..2e997f59f0b 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -9,8 +9,7 @@ import { EventType, addDisposableListener, getClientArea, Dimension, position, s import { onDidChangeFullscreen, isFullscreen } from 'vs/base/browser/browser'; import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup'; import { isWindows, isLinux, isMacintosh, isWeb, isNative, isIOS } from 'vs/base/common/platform'; -import { isResourceEditorInput, IUntypedEditorInput, pathsToEditors } from 'vs/workbench/common/editor'; -import { SideBySideEditorInput } from 'vs/workbench/common/editor/sideBySideEditorInput'; +import { EditorInputCapabilities, isResourceEditorInput, IUntypedEditorInput, pathsToEditors } from 'vs/workbench/common/editor'; import { SidebarPart } from 'vs/workbench/browser/parts/sidebar/sidebarPart'; import { PanelPart } from 'vs/workbench/browser/parts/panel/panelPart'; import { Position, Parts, PanelOpensMaximizedOptions, IWorkbenchLayoutService, positionFromString, positionToString, panelOpensMaximizedFromString, PanelAlignment } from 'vs/workbench/services/layout/browser/layoutService'; @@ -1309,27 +1308,25 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi centerEditorLayout(active: boolean, skipLayout?: boolean): void { this.stateModel.setRuntimeValue(LayoutStateKeys.EDITOR_CENTERED, active); - let smartActive = active; const activeEditor = this.editorService.activeEditor; - let isEditorSplit = false; + let isEditorComplex = false; if (activeEditor instanceof DiffEditorInput) { - isEditorSplit = this.configurationService.getValue('diffEditor.renderSideBySide'); - } else if (activeEditor instanceof SideBySideEditorInput) { - isEditorSplit = true; + isEditorComplex = this.configurationService.getValue('diffEditor.renderSideBySide'); + } else if (activeEditor?.hasCapability(EditorInputCapabilities.MultipleEditors)) { + isEditorComplex = true; } const isCenteredLayoutAutoResizing = this.configurationService.getValue('workbench.editor.centeredLayoutAutoResize'); if ( isCenteredLayoutAutoResizing && - (this.editorGroupService.groups.length > 1 || isEditorSplit) + (this.editorGroupService.groups.length > 1 || isEditorComplex) ) { - smartActive = false; + active = false; // disable centered layout for complex editors or when there is more than one group } - // Enter Centered Editor Layout - if (this.editorGroupService.isLayoutCentered() !== smartActive) { - this.editorGroupService.centerLayout(smartActive); + if (this.editorGroupService.isLayoutCentered() !== active) { + this.editorGroupService.centerLayout(active); if (!skipLayout) { this.layout(); diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts index 8928ff0036f..6f6ab509248 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -733,6 +733,12 @@ export const enum EditorInputCapabilities { * editor by holding shift. */ CanDropIntoEditor = 1 << 7, + + /** + * Signals that the editor is composed of multiple editors + * within. + */ + MultipleEditors = 1 << 8 } export type IUntypedEditorInput = IResourceEditorInput | ITextResourceEditorInput | IUntitledTextResourceEditorInput | IResourceDiffEditorInput | IResourceSideBySideEditorInput | IResourceMergeEditorInput; diff --git a/src/vs/workbench/common/editor/sideBySideEditorInput.ts b/src/vs/workbench/common/editor/sideBySideEditorInput.ts index 4151bf90118..d36c91348a4 100644 --- a/src/vs/workbench/common/editor/sideBySideEditorInput.ts +++ b/src/vs/workbench/common/editor/sideBySideEditorInput.ts @@ -42,6 +42,9 @@ export class SideBySideEditorInput extends EditorInput implements ISideBySideEdi capabilities |= EditorInputCapabilities.Singleton; } + // Indicate we show more than one editor + capabilities |= EditorInputCapabilities.MultipleEditors; + return capabilities; } diff --git a/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.ts b/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.ts index 7f5a2febdb7..9a4286f26b6 100644 --- a/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.ts +++ b/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.ts @@ -13,7 +13,7 @@ import { ConfirmResult, IDialogService } from 'vs/platform/dialogs/common/dialog import { IFileService } from 'vs/platform/files/common/files'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ILabelService } from 'vs/platform/label/common/label'; -import { IEditorIdentifier, IResourceMergeEditorInput, isResourceMergeEditorInput, IUntypedEditorInput } from 'vs/workbench/common/editor'; +import { EditorInputCapabilities, IEditorIdentifier, IResourceMergeEditorInput, isResourceMergeEditorInput, IUntypedEditorInput } from 'vs/workbench/common/editor'; import { EditorInput, IEditorCloseHandler } from 'vs/workbench/common/editor/editorInput'; import { AbstractTextResourceEditorInput } from 'vs/workbench/common/editor/textResourceEditorInput'; import { EditorWorkerServiceDiffComputer } from 'vs/workbench/contrib/mergeEditor/browser/model/diffComputer'; @@ -84,6 +84,10 @@ export class MergeEditorInput extends AbstractTextResourceEditorInput implements return MergeEditorInput.ID; } + override get capabilities(): EditorInputCapabilities { + return super.capabilities | EditorInputCapabilities.MultipleEditors; + } + override getName(): string { return localize('name', "Merging: {0}", super.getName()); } diff --git a/src/vs/workbench/test/browser/parts/editor/editor.test.ts b/src/vs/workbench/test/browser/parts/editor/editor.test.ts index 453705ac39f..df4f76fb26e 100644 --- a/src/vs/workbench/test/browser/parts/editor/editor.test.ts +++ b/src/vs/workbench/test/browser/parts/editor/editor.test.ts @@ -120,7 +120,7 @@ suite('Workbench editor utils', () => { testInput2.capabilities = EditorInputCapabilities.None; const sideBySideInput = instantiationService.createInstance(SideBySideEditorInput, 'name', undefined, testInput1, testInput2); - assert.strictEqual(sideBySideInput.hasCapability(EditorInputCapabilities.None), true); + assert.strictEqual(sideBySideInput.hasCapability(EditorInputCapabilities.MultipleEditors), true); assert.strictEqual(sideBySideInput.hasCapability(EditorInputCapabilities.Readonly), false); assert.strictEqual(sideBySideInput.hasCapability(EditorInputCapabilities.Untitled), false); assert.strictEqual(sideBySideInput.hasCapability(EditorInputCapabilities.RequiresTrust), false);