diff --git a/src/vs/workbench/browser/parts/editor2/nextEditorPart.ts b/src/vs/workbench/browser/parts/editor2/nextEditorPart.ts index 371b1d039fcd6da107c90868d9bfd3dd66814abe..3e46d45bce506d7faefb330a4177a7f41221a1d8 100644 --- a/src/vs/workbench/browser/parts/editor2/nextEditorPart.ts +++ b/src/vs/workbench/browser/parts/editor2/nextEditorPart.ts @@ -29,8 +29,6 @@ import { assign } from 'vs/base/common/objects'; // - editor: move/copy to existing group, move/copy to new split group (up, down, left, right) // - group: move/copy to existing group (merges?), move/copy to new split group (up, down, left, right) -// TODO@grid enable centered editor layout if one group is visible and centered editor layout is enabled (IPartService#isEditorLayoutCentered(), should this move here?) - // TODO@grid enable double click on sash to even out widths in one dimension // TODO@grid enable minimized/maximized groups in one dimension diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 6de476c7f2cc5b29edd79ea999f51a2bebc2443b..d4a426068ec53239a97a55a6b69d8ccb82629d4e 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -110,7 +110,7 @@ import { IPreferencesService } from 'vs/workbench/services/preferences/common/pr import { PreferencesService } from 'vs/workbench/services/preferences/browser/preferencesService'; import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService'; import { NextEditorPart } from 'vs/workbench/browser/parts/editor2/nextEditorPart'; -import { INextEditorGroupsService } from 'vs/workbench/services/editor/common/nextEditorGroupsService'; +import { INextEditorGroupsService, Direction } from 'vs/workbench/services/editor/common/nextEditorGroupsService'; import { NextEditorService } from 'vs/workbench/services/editor/browser/nextEditorService'; import { IExtensionUrlHandler, ExtensionUrlHandler } from 'vs/platform/url/electron-browser/inactiveExtensionUrlHandler'; @@ -1402,10 +1402,34 @@ export class Workbench extends Disposable implements IPartService { return this.centeredEditorLayoutActive; } + // TODO@grid support centered editor layout using empty groups or not? functionality missing: + // - proper initial sizing (left and right empty group sizes are not the same) + // - resize sashes left and right in sync + // - IEditorInput.supportsCenteredEditorLayout() no longer supported centerEditorLayout(active: boolean, skipLayout?: boolean): void { this.centeredEditorLayoutActive = active; this.storageService.store(Workbench.centeredEditorLayoutActiveStorageKey, this.centeredEditorLayoutActive, StorageScope.GLOBAL); + // Enter Centered Editor Layout + if (active) { + if (this.nextEditorGroupsService.count === 1) { + const activeGroup = this.nextEditorGroupsService.activeGroup; + this.nextEditorGroupsService.addGroup(activeGroup, Direction.LEFT); + this.nextEditorGroupsService.addGroup(activeGroup, Direction.RIGHT); + } + } + + // Leave Centered Editor Layout + else { + if (this.nextEditorGroupsService.count === 3) { + this.nextEditorGroupsService.groups.forEach(group => { + if (group.count === 0) { + this.nextEditorGroupsService.removeGroup(group); + } + }); + } + } + if (!skipLayout) { this.layout(); }