Skip to content

Commit a76b835

Browse files
committed
aux window - limit centered layout to main part for now
1 parent cb33247 commit a76b835

File tree

6 files changed

+37
-44
lines changed

6 files changed

+37
-44
lines changed

src/vs/workbench/browser/actions/layoutActions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/b
2121
import { ToggleAuxiliaryBarAction } from 'vs/workbench/browser/parts/auxiliarybar/auxiliaryBarActions';
2222
import { TogglePanelAction } from 'vs/workbench/browser/parts/panel/panelActions';
2323
import { ICommandService } from 'vs/platform/commands/common/commands';
24-
import { AuxiliaryBarVisibleContext, PanelAlignmentContext, PanelVisibleContext, SideBarVisibleContext, FocusedViewContext, InEditorZenModeContext, IsCenteredLayoutContext, EditorAreaVisibleContext, IsFullscreenContext, PanelPositionContext } from 'vs/workbench/common/contextkeys';
24+
import { AuxiliaryBarVisibleContext, PanelAlignmentContext, PanelVisibleContext, SideBarVisibleContext, FocusedViewContext, InEditorZenModeContext, IsCenteredLayoutContext, EditorAreaVisibleContext, IsFullscreenContext, PanelPositionContext, IsAuxiliaryWindowFocusedContext } from 'vs/workbench/common/contextkeys';
2525
import { Codicon } from 'vs/base/common/codicons';
2626
import { ThemeIcon } from 'vs/base/common/themables';
2727
import { DisposableStore } from 'vs/base/common/lifecycle';
@@ -81,6 +81,7 @@ registerAction2(class extends Action2 {
8181
mnemonicTitle: localize({ key: 'miToggleCenteredLayout', comment: ['&& denotes a mnemonic'] }, "&&Centered Layout"),
8282
original: 'Toggle Centered Layout'
8383
},
84+
precondition: IsAuxiliaryWindowFocusedContext.toNegated(),
8485
category: Categories.View,
8586
f1: true,
8687
toggled: IsCenteredLayoutContext,
@@ -95,7 +96,7 @@ registerAction2(class extends Action2 {
9596
run(accessor: ServicesAccessor): void {
9697
const layoutService = accessor.get(IWorkbenchLayoutService);
9798

98-
layoutService.centerEditorLayout(!layoutService.isEditorLayoutCentered());
99+
layoutService.centerMainEditorLayout(!layoutService.isMainEditorLayoutCentered());
99100
}
100101
});
101102

src/vs/workbench/browser/layout.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
335335
this._register(this.editorGroupService.mainPart.onDidActivateGroup(showEditorIfHidden));
336336

337337
// Revalidate center layout when active editor changes: diff editor quits centered mode.
338-
this._register(this.editorService.onDidActiveEditorChange(() => this.centerEditorLayout(this.stateModel.getRuntimeValue(LayoutStateKeys.EDITOR_CENTERED))));
338+
this._register(this.mainPartEditorService.onDidActiveEditorChange(() => this.centerMainEditorLayout(this.stateModel.getRuntimeValue(LayoutStateKeys.EDITOR_CENTERED))));
339339
});
340340

341341
// Configuration changes
@@ -358,8 +358,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
358358
this._register(onDidChangeFullscreen(() => this.onFullscreenChanged()));
359359

360360
// Group changes
361-
this._register(this.editorGroupService.onDidAddGroup(() => this.centerEditorLayout(this.stateModel.getRuntimeValue(LayoutStateKeys.EDITOR_CENTERED))));
362-
this._register(this.editorGroupService.onDidRemoveGroup(() => this.centerEditorLayout(this.stateModel.getRuntimeValue(LayoutStateKeys.EDITOR_CENTERED))));
361+
this._register(this.editorGroupService.mainPart.onDidAddGroup(() => this.centerMainEditorLayout(this.stateModel.getRuntimeValue(LayoutStateKeys.EDITOR_CENTERED))));
362+
this._register(this.editorGroupService.mainPart.onDidRemoveGroup(() => this.centerMainEditorLayout(this.stateModel.getRuntimeValue(LayoutStateKeys.EDITOR_CENTERED))));
363363

364364
// Prevent workbench from scrolling #55456
365365
this._register(addDisposableListener(this.mainContainer, EventType.SCROLL, () => this.mainContainer.scrollTop = 0));
@@ -485,7 +485,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
485485

486486
// Centered Layout
487487
this.editorGroupService.mainPart.whenRestored.then(() => {
488-
this.centerEditorLayout(this.stateModel.getRuntimeValue(LayoutStateKeys.EDITOR_CENTERED), skipLayout);
488+
this.centerMainEditorLayout(this.stateModel.getRuntimeValue(LayoutStateKeys.EDITOR_CENTERED), skipLayout);
489489
});
490490
}
491491

@@ -1047,9 +1047,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
10471047
this.toggleZenMode(false, true);
10481048
}
10491049

1050-
// Restore Editor Center Mode
1050+
// Restore Main Editor Center Mode
10511051
if (this.stateModel.getRuntimeValue(LayoutStateKeys.EDITOR_CENTERED)) {
1052-
this.centerEditorLayout(true, true);
1052+
this.centerMainEditorLayout(true, true);
10531053
}
10541054

10551055
// Await for promises that we recorded to update
@@ -1320,7 +1320,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
13201320

13211321
if (!restoring) {
13221322
zenModeExitInfo.transitionedToFullScreen = toggleFullScreen;
1323-
zenModeExitInfo.transitionedToCenteredEditorLayout = !this.isEditorLayoutCentered() && config.centerLayout;
1323+
zenModeExitInfo.transitionedToCenteredEditorLayout = !this.isMainEditorLayoutCentered() && config.centerLayout;
13241324
zenModeExitInfo.handleNotificationsDoNotDisturbMode = !this.notificationService.doNotDisturbMode;
13251325
zenModeExitInfo.wasVisible.sideBar = this.isVisible(Parts.SIDEBAR_PART);
13261326
zenModeExitInfo.wasVisible.panel = this.isVisible(Parts.PANEL_PART);
@@ -1362,7 +1362,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
13621362
}));
13631363

13641364
if (config.centerLayout) {
1365-
this.centerEditorLayout(true, true);
1365+
this.centerMainEditorLayout(true, true);
13661366
}
13671367
}
13681368

@@ -1389,7 +1389,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
13891389
}
13901390

13911391
if (zenModeExitInfo.transitionedToCenteredEditorLayout) {
1392-
this.centerEditorLayout(false, true);
1392+
this.centerMainEditorLayout(false, true);
13931393
}
13941394

13951395
if (zenModeExitInfo.handleNotificationsDoNotDisturbMode) {
@@ -1530,32 +1530,32 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
15301530
}
15311531
}
15321532

1533-
isEditorLayoutCentered(): boolean {
1533+
isMainEditorLayoutCentered(): boolean {
15341534
return this.stateModel.getRuntimeValue(LayoutStateKeys.EDITOR_CENTERED);
15351535
}
15361536

1537-
centerEditorLayout(active: boolean, skipLayout?: boolean): void {
1537+
centerMainEditorLayout(active: boolean, skipLayout?: boolean): void {
15381538
this.stateModel.setRuntimeValue(LayoutStateKeys.EDITOR_CENTERED, active);
15391539

1540-
const activeEditor = this.editorService.activeEditor;
1540+
const activeMainEditor = this.mainPartEditorService.activeEditor;
15411541

15421542
let isEditorComplex = false;
1543-
if (activeEditor instanceof DiffEditorInput) {
1543+
if (activeMainEditor instanceof DiffEditorInput) {
15441544
isEditorComplex = this.configurationService.getValue('diffEditor.renderSideBySide');
1545-
} else if (activeEditor?.hasCapability(EditorInputCapabilities.MultipleEditors)) {
1545+
} else if (activeMainEditor?.hasCapability(EditorInputCapabilities.MultipleEditors)) {
15461546
isEditorComplex = true;
15471547
}
15481548

15491549
const isCenteredLayoutAutoResizing = this.configurationService.getValue('workbench.editor.centeredLayoutAutoResize');
15501550
if (
15511551
isCenteredLayoutAutoResizing &&
1552-
(this.editorGroupService.groups.length > 1 || isEditorComplex)
1552+
(this.editorGroupService.mainPart.groups.length > 1 || isEditorComplex)
15531553
) {
15541554
active = false; // disable centered layout for complex editors or when there is more than one group
15551555
}
15561556

1557-
if (this.editorGroupService.isLayoutCentered() !== active) {
1558-
this.editorGroupService.centerLayout(active);
1557+
if (this.editorGroupService.mainPart.isLayoutCentered() !== active) {
1558+
this.editorGroupService.mainPart.centerLayout(active);
15591559

15601560
if (!skipLayout) {
15611561
this.layout();
@@ -1877,7 +1877,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
18771877
}
18781878

18791879
if (focusEditor) {
1880-
this.editorGroupService.activeGroup.focus(); // Pass focus to editor group if panel part is now hidden
1880+
this.editorGroupService.mainPart.activeGroup.focus(); // Pass focus to editor group if panel part is now hidden
18811881
}
18821882
}
18831883

src/vs/workbench/browser/parts/editor/editorParts.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,6 @@ export class EditorParts extends Disposable implements IEditorGroupsService, IEd
297297
return this.activePart.getLayout();
298298
}
299299

300-
centerLayout(active: boolean): void {
301-
this.activePart.centerLayout(active);
302-
}
303-
304-
isLayoutCentered(): boolean {
305-
return this.activePart.isLayoutCentered();
306-
}
307-
308300
get orientation() {
309301
return this.activePart.orientation;
310302
}

src/vs/workbench/services/editor/common/editorGroupsService.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -301,16 +301,6 @@ export interface IEditorGroupsContainer {
301301
*/
302302
getLayout(): EditorGroupLayout;
303303

304-
/**
305-
* Enable or disable centered editor layout.
306-
*/
307-
centerLayout(active: boolean): void;
308-
309-
/**
310-
* Find out if the editor layout is currently centered.
311-
*/
312-
isLayoutCentered(): boolean;
313-
314304
/**
315305
* Sets the orientation of the root group to be either vertical or horizontal.
316306
*/
@@ -462,6 +452,16 @@ export interface IEditorPart extends IEditorGroupsContainer {
462452
* from a previous session.
463453
*/
464454
readonly hasRestorableState: boolean;
455+
456+
/**
457+
* Enable or disable centered editor layout.
458+
*/
459+
centerLayout(active: boolean): void;
460+
461+
/**
462+
* Find out if the editor layout is currently centered.
463+
*/
464+
isLayoutCentered(): boolean;
465465
}
466466

467467
export interface IAuxiliaryEditorPart extends IEditorPart {

src/vs/workbench/services/layout/browser/layoutService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,14 @@ export interface IWorkbenchLayoutService extends ILayoutService {
256256
toggleZenMode(): void;
257257

258258
/**
259-
* Returns whether the centered editor layout is active.
259+
* Returns whether the centered editor layout is active on the main editor part.
260260
*/
261-
isEditorLayoutCentered(): boolean;
261+
isMainEditorLayoutCentered(): boolean;
262262

263263
/**
264-
* Sets the workbench in and out of centered editor layout.
264+
* Sets the main editor part in and out of centered layout.
265265
*/
266-
centerEditorLayout(active: boolean): void;
266+
centerMainEditorLayout(active: boolean): void;
267267

268268
/**
269269
* Resizes currently focused part on main access

src/vs/workbench/test/browser/workbenchTestServices.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,8 @@ export class TestLayoutService implements IWorkbenchLayoutService {
649649
removeClass(_clazz: string): void { }
650650
getMaximumEditorDimensions(): IDimension { throw new Error('not implemented'); }
651651
toggleZenMode(): void { }
652-
isEditorLayoutCentered(): boolean { return false; }
653-
centerEditorLayout(_active: boolean): void { }
652+
isMainEditorLayoutCentered(): boolean { return false; }
653+
centerMainEditorLayout(_active: boolean): void { }
654654
resizePart(_part: Parts, _sizeChangeWidth: number, _sizeChangeHeight: number): void { }
655655
registerPart(part: Part): void { }
656656
isWindowMaximized() { return false; }

0 commit comments

Comments
 (0)