Skip to content

Commit 8ce742c

Browse files
authored
Restoring to a maximised secondary sidebar on startup needs workarounds (fix microsoft#252465) (microsoft#255046)
1 parent 55cf9aa commit 8ce742c

File tree

1 file changed

+24
-56
lines changed

1 file changed

+24
-56
lines changed

src/vs/workbench/browser/layout.ts

Lines changed: 24 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,16 +1565,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
15651565
this.workbenchGrid = workbenchGrid;
15661566
this.workbenchGrid.edgeSnapping = this.state.runtime.mainWindowFullscreen;
15671567

1568-
if (this.stateModel.getRuntimeValue(LayoutStateKeys.AUXILIARYBAR_WAS_LAST_MAXIMIZED)) {
1569-
// TODO@benibenj this is a workaround for the grid not being able to
1570-
// restore the maximized auxiliary bar on startup when it was maximised
1571-
// It seems that since editor and panel are hidden, the parent node is
1572-
// also hidden and not present, breaking the layout.
1573-
// Workaround is to make editor visible so that its parent view gets
1574-
// added properly and then enter maximized mode of auxiliary bar.
1575-
this.setAuxiliaryBarMaximized(true, true /* fromInit */);
1576-
}
1577-
15781568
for (const part of [titleBar, editorPart, activityBar, panelPart, sideBar, statusBar, auxiliaryBarPart, bannerPart]) {
15791569
this._register(part.onDidVisibilityChange(visible => {
15801570
if (!this.inMaximizedAuxiliaryBarTransition) {
@@ -2023,63 +2013,42 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
20232013
}
20242014
}
20252015

2026-
private maximizedAuxiliaryBarState: {
2027-
sideBarVisible: boolean;
2028-
editorVisible: boolean;
2029-
panelVisible: boolean;
2030-
auxiliaryBarVisible: boolean;
2031-
} | undefined = undefined;
2032-
20332016
private inMaximizedAuxiliaryBarTransition = false;
20342017

20352018
isAuxiliaryBarMaximized(): boolean {
2036-
return !!this.maximizedAuxiliaryBarState;
2019+
return this.stateModel.getRuntimeValue(LayoutStateKeys.AUXILIARYBAR_WAS_LAST_MAXIMIZED);
20372020
}
20382021

20392022
toggleMaximizedAuxiliaryBar(): void {
20402023
this.setAuxiliaryBarMaximized(!this.isAuxiliaryBarMaximized());
20412024
}
20422025

2043-
setAuxiliaryBarMaximized(maximized: boolean, fromInit?: boolean): boolean {
2026+
setAuxiliaryBarMaximized(maximized: boolean): boolean {
20442027
if (
2045-
this.inMaximizedAuxiliaryBarTransition || // prevent re-entrance
2046-
(!maximized && !this.maximizedAuxiliaryBarState) // return early if not maximizing and no state
2028+
this.inMaximizedAuxiliaryBarTransition || // prevent re-entrance
2029+
(maximized === this.isAuxiliaryBarMaximized()) // return early if state is already present
20472030
) {
20482031
return false;
20492032
}
20502033

20512034
if (maximized) {
2052-
let state: typeof this.maximizedAuxiliaryBarState;
2053-
if (fromInit) {
2054-
2055-
// TODO workaround for a bug with grid, see above in `createWorkbenchLayout`
2056-
const stateMixin = { editorVisible: true };
2057-
this.setEditorHidden(false);
2058-
// TODO workaround
2059-
2060-
state = {
2061-
...this.stateModel.getRuntimeValue(LayoutStateKeys.AUXILIARYBAR_LAST_NON_MAXIMIZED_VISIBILITY),
2062-
...stateMixin
2063-
};
2064-
} else {
2065-
state = {
2066-
sideBarVisible: this.isVisible(Parts.SIDEBAR_PART),
2067-
editorVisible: this.isVisible(Parts.EDITOR_PART),
2068-
panelVisible: this.isVisible(Parts.PANEL_PART),
2069-
auxiliaryBarVisible: this.isVisible(Parts.AUXILIARYBAR_PART)
2070-
};
2071-
}
2072-
this.maximizedAuxiliaryBarState = state;
2035+
const state = {
2036+
sideBarVisible: this.isVisible(Parts.SIDEBAR_PART),
2037+
editorVisible: this.isVisible(Parts.EDITOR_PART),
2038+
panelVisible: this.isVisible(Parts.PANEL_PART),
2039+
auxiliaryBarVisible: this.isVisible(Parts.AUXILIARYBAR_PART)
2040+
};
2041+
this.stateModel.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_WAS_LAST_MAXIMIZED, true);
20732042

20742043
this.inMaximizedAuxiliaryBarTransition = true;
20752044
try {
20762045
if (!state.auxiliaryBarVisible) {
20772046
this.setAuxiliaryBarHidden(false);
20782047
}
2079-
if (!fromInit) {
2080-
const size = this.workbenchGrid.getViewSize(this.auxiliaryBarPartView).width;
2081-
this.stateModel.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_LAST_NON_MAXIMIZED_SIZE, size);
2082-
}
2048+
2049+
const size = this.workbenchGrid.getViewSize(this.auxiliaryBarPartView).width;
2050+
this.stateModel.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_LAST_NON_MAXIMIZED_SIZE, size);
2051+
20832052
if (state.sideBarVisible) {
20842053
this.setSideBarHidden(true);
20852054
}
@@ -2090,15 +2059,13 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
20902059
this.setEditorHidden(true);
20912060
}
20922061

2093-
if (!fromInit) {
2094-
this.stateModel.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_LAST_NON_MAXIMIZED_VISIBILITY, state);
2095-
}
2062+
this.stateModel.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_LAST_NON_MAXIMIZED_VISIBILITY, state);
20962063
} finally {
20972064
this.inMaximizedAuxiliaryBarTransition = false;
20982065
}
20992066
} else {
2100-
const state = assertReturnsDefined(this.maximizedAuxiliaryBarState);
2101-
this.maximizedAuxiliaryBarState = undefined;
2067+
const state = assertReturnsDefined(this.stateModel.getRuntimeValue(LayoutStateKeys.AUXILIARYBAR_LAST_NON_MAXIMIZED_VISIBILITY));
2068+
this.stateModel.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_WAS_LAST_MAXIMIZED, false);
21022069

21032070
this.inMaximizedAuxiliaryBarTransition = true;
21042071
try {
@@ -2118,8 +2085,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
21182085

21192086
this.focusPart(Parts.AUXILIARYBAR_PART);
21202087

2121-
this.stateModel.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_WAS_LAST_MAXIMIZED, maximized);
2122-
21232088
this._onDidChangeAuxiliaryBarMaximized.fire();
21242089

21252090
return true;
@@ -2451,7 +2416,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
24512416
return {
24522417
type: 'branch',
24532418
data: result,
2454-
size: availableHeight
2419+
size: availableHeight,
2420+
visible: result.some(node => node.visible)
24552421
};
24562422
}
24572423

@@ -2496,10 +2462,12 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
24962462
auxiliaryBar: auxiliaryBarNextToEditor ? nodes.auxiliaryBar : undefined
24972463
}, availableHeight - panelSize, editorSectionWidth);
24982464

2465+
const data = panelPostion === Position.BOTTOM ? [editorNodes, nodes.panel] : [nodes.panel, editorNodes];
24992466
result.push({
25002467
type: 'branch',
2501-
data: panelPostion === Position.BOTTOM ? [editorNodes, nodes.panel] : [nodes.panel, editorNodes],
2502-
size: editorSectionWidth
2468+
data,
2469+
size: editorSectionWidth,
2470+
visible: data.some(node => node.visible)
25032471
});
25042472

25052473
if (!sideBarNextToEditor) {

0 commit comments

Comments
 (0)