Merge from vscode 6268feb42ba4f2e2fa15484e88c9af60d254998c (#6530)

This commit is contained in:
Anthony Dresser
2019-07-29 21:03:02 -07:00
committed by GitHub
parent 2c8a22bb0d
commit 6db84eefa3
104 changed files with 1797 additions and 3740 deletions

View File

@@ -27,7 +27,7 @@ import { IWindowService, MenuBarVisibility, getTitleBarStyle } from 'vs/platform
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IEditorService, IResourceEditor } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { Sizing, Direction, Grid, SerializableGrid, ISerializableView, ISerializedGrid } from 'vs/base/browser/ui/grid/grid';
import { Sizing, Direction, Grid, SerializableGrid, ISerializableView, ISerializedGrid, GridBranchNode, GridLeafNode, isGridBranchNode } from 'vs/base/browser/ui/grid/grid';
import { WorkbenchLegacyLayout } from 'vs/workbench/browser/legacyLayout';
import { IDimension } from 'vs/platform/layout/browser/layoutService';
import { Part } from 'vs/workbench/browser/part';
@@ -749,21 +749,25 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
try {
workbenchGrid = SerializableGrid.deserialize(parsedGrid, { fromJSON }, { proportionalLayout: false });
// Set some layout state
this.state.sideBar.position = Position.LEFT;
for (let view of workbenchGrid.getNeighborViews(this.sideBarPartView, Direction.Right)) {
if (view === this.activityBarPartView) {
this.state.sideBar.position = Position.RIGHT;
}
const root = workbenchGrid.getViews();
const titleBarSection = root.children[0];
if (isGridBranchNode(titleBarSection) || titleBarSection.view !== this.titleBarPartView) {
throw new Error('Bad grid');
}
this.state.panel.position = Position.BOTTOM;
for (let view of workbenchGrid.getNeighborViews(this.panelPartView, Direction.Left)) {
if (view === this.editorPartView) {
this.state.panel.position = Position.RIGHT;
}
const middleSection = root.children[1] as GridBranchNode<ISerializableView>;
const sideBarPosition = (middleSection.children[0] as GridLeafNode<ISerializableView>).view === this.activityBarPartView ? Position.LEFT : Position.RIGHT;
if (sideBarPosition !== this.state.sideBar.position) {
throw new Error('Bad Grid');
}
const panelPosition = isGridBranchNode(middleSection.children[2]) || isGridBranchNode(middleSection.children[0]) ? Position.BOTTOM : Position.RIGHT;
if (panelPosition !== this.state.panel.position) {
throw new Error('Bad Grid');
}
} catch (err) {
workbenchGrid = undefined;
console.error(err);
}
}
@@ -783,6 +787,10 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this.setPanelHidden(!visible, true);
}));
this._register((this.editorPartView as PanelPart).onDidVisibilityChange((visible) => {
this.setEditorHidden(!visible, true);
}));
this._register(this.lifecycleService.onBeforeShutdown(beforeShutdownEvent => {
beforeShutdownEvent.veto(new Promise((resolve) => {
const grid = this.workbenchGrid as SerializableGrid<ISerializableView>;
@@ -849,8 +857,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
statusBarInGrid = true;
}
if (!titlebarInGrid && getTitleBarStyle(this.configurationService, this.environmentService) === 'custom') {
if (!titlebarInGrid) {
this.workbenchGrid.addView(this.titleBarPartView, Sizing.Split, this.editorPartView, Direction.Up);
titlebarInGrid = true;
}
@@ -1157,6 +1166,11 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
} else {
size.width = this.state.panel.sizeBeforeMaximize;
}
// Unhide the editor if needed
if (this.state.editor.hidden) {
this.setEditorHidden(false);
}
}
this.workbenchGrid.resizeView(this.panelPartView, size);
@@ -1166,6 +1180,10 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
}
isPanelMaximized(): boolean {
if (!this.workbenchGrid) {
return false;
}
if (this.workbenchGrid instanceof Grid) {
try {
// The panel is maximum when the editor is minimum