Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the inline diff editor to be centered. #97311

Merged
merged 1 commit into from May 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/vs/workbench/browser/layout.ts
Expand Up @@ -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',
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down