diff --git a/src/vs/workbench/browser/actions/toggleCenteredLayout.ts b/src/vs/workbench/browser/actions/toggleCenteredLayout.ts index 669820dc5efdbe67290a5209811fba0bde196fc3..0b3680cd1700c1fdf5826fa2287c6c8c64c34aac 100644 --- a/src/vs/workbench/browser/actions/toggleCenteredLayout.ts +++ b/src/vs/workbench/browser/actions/toggleCenteredLayout.ts @@ -26,11 +26,11 @@ class ToggleCenteredLayout extends Action { } public run(): TPromise { - this.partService.toggleCenteredEditorLayout(); + this.partService.centerEditorLayout(!this.partService.isEditorLayoutCentered()); return TPromise.as(null); } } const registry = Registry.as(Extensions.WorkbenchActions); -registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleCenteredLayout, ToggleCenteredLayout.ID, ToggleCenteredLayout.LABEL), 'View: Toggle Centered Layout', nls.localize('view', "View")); \ No newline at end of file +registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleCenteredLayout, ToggleCenteredLayout.ID, ToggleCenteredLayout.LABEL), 'View: Toggle Centered Layout', nls.localize('view', "View")); diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 78647ff9794f8ffde9ed9bd48b0fc1652eda46f1..384c0c9b2f7b555875b6eed9996a295307e045e7 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -1319,13 +1319,11 @@ export class Workbench implements IPartService { // Check if zen mode transitioned to full screen and if now we are out of zen mode -> we need to go out of full screen let toggleFullScreen = false; // Same goes for the centered editor layout - let toggleCenteredEditorLayout = false; if (this.zenMode.active) { const config = this.configurationService.getValue('zenMode'); toggleFullScreen = !browser.isFullscreen() && config.fullScreen; this.zenMode.transitionedToFullScreen = toggleFullScreen; - toggleCenteredEditorLayout = !this.isEditorLayoutCentered() && config.centerLayout; - this.zenMode.transitionedToCenteredEditorLayout = toggleCenteredEditorLayout; + this.zenMode.transitionedToCenteredEditorLayout = !this.isEditorLayoutCentered() && config.centerLayout; this.zenMode.wasSideBarVisible = this.isVisible(Parts.SIDEBAR_PART); this.zenMode.wasPanelVisible = this.isVisible(Parts.PANEL_PART); this.setPanelHidden(true, true).done(void 0, errors.onUnexpectedError); @@ -1342,14 +1340,20 @@ export class Workbench implements IPartService { if (config.hideTabs) { this.editorPart.hideTabs(true); } + + if (config.centerLayout) { + this.centerEditorLayout(true, true); + } } else { if (this.zenMode.wasPanelVisible) { this.setPanelHidden(false, true).done(void 0, errors.onUnexpectedError); } - if (this.zenMode.wasSideBarVisible) { this.setSideBarHidden(false, true).done(void 0, errors.onUnexpectedError); } + if (this.zenMode.transitionedToCenteredEditorLayout) { + this.centerEditorLayout(false, true); + } // Status bar and activity bar visibility come from settings -> update their visibility. this.onDidUpdateConfiguration(true); @@ -1360,15 +1364,10 @@ export class Workbench implements IPartService { } toggleFullScreen = this.zenMode.transitionedToFullScreen && browser.isFullscreen(); - toggleCenteredEditorLayout = this.zenMode.transitionedToCenteredEditorLayout && this.isEditorLayoutCentered(); } this.inZenMode.set(this.zenMode.active); - if (toggleCenteredEditorLayout) { - this.toggleCenteredEditorLayout(true); - } - if (!skipLayout) { this.layout(); } @@ -1382,8 +1381,8 @@ export class Workbench implements IPartService { return this.centeredEditorLayoutActive; } - public toggleCenteredEditorLayout(skipLayout?: boolean): void { - this.centeredEditorLayoutActive = !this.centeredEditorLayoutActive; + public centerEditorLayout(active: boolean, skipLayout?: boolean): void { + this.centeredEditorLayoutActive = active; this.storageService.store(Workbench.centeredEditorLayoutActiveStorageKey, this.centeredEditorLayoutActive, StorageScope.GLOBAL); if (!skipLayout) { diff --git a/src/vs/workbench/services/part/common/partService.ts b/src/vs/workbench/services/part/common/partService.ts index b56e8c8fe1d006503df5827b3fc8f643a2e47561..f6749a80a3fcf739c2deecbf0908354431a78d70 100644 --- a/src/vs/workbench/services/part/common/partService.ts +++ b/src/vs/workbench/services/part/common/partService.ts @@ -135,12 +135,12 @@ export interface IPartService { isEditorLayoutCentered(): boolean; /** - * Toggles the workbench in and out of centered editor layout. + * Sets the workbench in and out of centered editor layout. */ - toggleCenteredEditorLayout(): void; + centerEditorLayout(active: boolean): void; /** * Resizes currently focused part on main access */ resizePart(part: Parts, sizeChange: number): void; -} \ No newline at end of file +} diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index ca255a106e17fc1366bcef617ed0c3720271b80b..bf33bed29939961774db488d31a337a2cc028e5d 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -433,7 +433,7 @@ export class TestPartService implements IPartService { public toggleZenMode(): void { } public isEditorLayoutCentered(): boolean { return false; } - public toggleCenteredEditorLayout(): void { } + public centerEditorLayout(active: boolean): void { } public resizePart(part: Parts, sizeChange: number): void { }