提交 d3c7be9f 编写于 作者: I isidor

zenMode: properly get in and out of center mode

fixes #45610
上级 459e4d49
......@@ -26,11 +26,11 @@ class ToggleCenteredLayout extends Action {
}
public run(): TPromise<any> {
this.partService.toggleCenteredEditorLayout();
this.partService.centerEditorLayout(!this.partService.isEditorLayoutCentered());
return TPromise.as(null);
}
}
const registry = Registry.as<IWorkbenchActionRegistry>(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"));
......@@ -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<IZenModeSettings>('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) {
......
......@@ -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
}
......@@ -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 { }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册