Skip to content

Commit

Permalink
restore maximized panel
Browse files Browse the repository at this point in the history
fixes #79891
  • Loading branch information
sbatten committed Sep 24, 2019
1 parent 8a269f2 commit 5666547
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/vs/workbench/browser/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,15 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
private registerLayoutListeners(): void {

// Restore editor if hidden and it changes
// The editor service will always trigger this
// on startup so we can ignore the first one
let firstTimeEditorActivation = true;

This comment has been minimized.

Copy link
@sbatten

sbatten Sep 24, 2019

Author Member

The editor service always fires this on launch even if it is not visible. Maybe this could be updated? @bpasero

This comment has been minimized.

Copy link
@bpasero

bpasero Sep 24, 2019

Member

@sbatten fires what event?

This comment has been minimized.

Copy link
@bpasero

bpasero Sep 24, 2019

Member

@sbatten I see, this is about editor events. i think this is OK, the editor itself does not really know if it is visible from the layout or not, or is it? I am a bit afraid to not send this event, there is quite a bit of listeners that will rely on the event being fired on startup...

const showEditorIfHidden = () => {
if (this.state.editor.hidden) {
if (!firstTimeEditorActivation && this.state.editor.hidden) {
this.toggleMaximizedPanel();
}

firstTimeEditorActivation = false;
};

// Restore editor part on any editor change
Expand Down Expand Up @@ -410,6 +415,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
}
}

// Editor visibility
this.state.editor.hidden = this.storageService.getBoolean(Storage.EDITOR_HIDDEN, StorageScope.WORKSPACE, false);

// Editor centered layout
this.state.editor.restoreCentered = this.storageService.getBoolean(Storage.CENTERED_LAYOUT_ENABLED, StorageScope.WORKSPACE, false);

Expand Down Expand Up @@ -1180,7 +1188,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
// At some point, we will not fall back to old keys from legacy layout, but for now, let's migrate the keys
const sideBarSize = this.storageService.getNumber(Storage.SIDEBAR_SIZE, StorageScope.GLOBAL, this.storageService.getNumber('workbench.sidebar.width', StorageScope.GLOBAL, Math.min(workbenchDimensions.width / 4, 300))!);
const panelSize = this.storageService.getNumber(Storage.PANEL_SIZE, StorageScope.GLOBAL, this.storageService.getNumber(this.state.panel.position === Position.BOTTOM ? 'workbench.panel.height' : 'workbench.panel.width', StorageScope.GLOBAL, workbenchDimensions.height / 3));
const wasEditorHidden = this.storageService.getBoolean(Storage.EDITOR_HIDDEN, StorageScope.WORKSPACE, false);

const titleBarHeight = this.titleBarPartView.minimumHeight;
const statusBarHeight = this.statusBarPartView.minimumHeight;
Expand All @@ -1205,14 +1212,16 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
const editorNode: ISerializedLeafNode = {
type: 'leaf',
data: { type: Parts.EDITOR_PART },
size: this.state.panel.position === Position.BOTTOM ? middleSectionHeight - (this.state.panel.hidden ? 0 : panelSize) : editorSectionWidth - (this.state.panel.hidden ? 0 : panelSize),
visible: true
size: this.state.panel.position === Position.BOTTOM ?
middleSectionHeight - (this.state.panel.hidden ? 0 : panelSize) :
editorSectionWidth - (this.state.panel.hidden ? 0 : panelSize),
visible: !this.state.editor.hidden
};

const panelNode: ISerializedLeafNode = {
type: 'leaf',
data: { type: Parts.PANEL_PART },
size: wasEditorHidden ? (this.state.panel.position === Position.BOTTOM ? this.state.panel.lastNonMaximizedHeight : this.state.panel.lastNonMaximizedWidth) : panelSize,
size: panelSize,
visible: !this.state.panel.hidden
};

Expand Down

0 comments on commit 5666547

Please sign in to comment.