mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
This commit is contained in:
parent
a74adedba8
commit
36f146381b
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue