@@ -58,7 +58,8 @@ enum Storage {
5858 PANEL_HIDDEN = 'workbench.panel.hidden' ,
5959 PANEL_POSITION = 'workbench.panel.location' ,
6060 PANEL_SIZE = 'workbench.panel.size' ,
61- PANEL_SIZE_BEFORE_MAXIMIZED = 'workbench.panel.sizeBeforeMaximized' ,
61+ PANEL_LAST_NON_MAXIMIZED_WIDTH = 'workbench.panel.lastNonMaximizedWidth' ,
62+ PANEL_LAST_NON_MAXIMIZED_HEIGHT = 'workbench.panel.lastNonMaximizedHeight' ,
6263
6364 EDITOR_HIDDEN = 'workbench.editor.hidden' ,
6465
@@ -165,8 +166,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
165166
166167 panel : {
167168 hidden : false ,
168- sizeBeforeMaximize : 0 ,
169169 position : Position . BOTTOM ,
170+ lastNonMaximizedWidth : 300 ,
171+ lastNonMaximizedHeight : 300 ,
170172 panelToRestore : undefined as string | undefined
171173 } ,
172174
@@ -437,7 +439,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
437439 }
438440
439441 // Panel size before maximized
440- this . state . panel . sizeBeforeMaximize = this . storageService . getNumber ( Storage . PANEL_SIZE_BEFORE_MAXIMIZED , StorageScope . GLOBAL , 0 ) ;
442+ this . state . panel . lastNonMaximizedHeight = this . storageService . getNumber ( Storage . PANEL_LAST_NON_MAXIMIZED_HEIGHT , StorageScope . GLOBAL , 300 ) ;
443+ this . state . panel . lastNonMaximizedWidth = this . storageService . getNumber ( Storage . PANEL_LAST_NON_MAXIMIZED_WIDTH , StorageScope . GLOBAL , 300 ) ;
441444
442445 // Statusbar visibility
443446 this . state . statusBar . hidden = ! this . configurationService . getValue < string > ( Settings . STATUSBAR_VISIBLE ) ;
@@ -1065,17 +1068,20 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
10651068 toggleMaximizedPanel ( ) : void {
10661069 const size = this . workbenchGrid . getViewSize ( this . panelPartView ) ;
10671070 if ( ! this . isPanelMaximized ( ) ) {
1068- if ( this . state . panel . hidden ) {
1069- this . state . panel . sizeBeforeMaximize = this . workbenchGrid . getViewCachedVisibleSize ( this . panelPartView ) || this . panelPartView . minimumHeight ;
1070- } else {
1071- this . state . panel . sizeBeforeMaximize = this . state . panel . position === Position . BOTTOM ? size . height : size . width ;
1071+ if ( ! this . state . panel . hidden ) {
1072+ if ( this . state . panel . position === Position . BOTTOM ) {
1073+ this . state . panel . lastNonMaximizedHeight = size . height ;
1074+ this . storageService . store ( Storage . PANEL_LAST_NON_MAXIMIZED_HEIGHT , this . state . panel . lastNonMaximizedHeight , StorageScope . GLOBAL ) ;
1075+ } else {
1076+ this . state . panel . lastNonMaximizedWidth = size . width ;
1077+ this . storageService . store ( Storage . PANEL_LAST_NON_MAXIMIZED_WIDTH , this . state . panel . lastNonMaximizedWidth , StorageScope . GLOBAL ) ;
1078+ }
10721079 }
10731080
1074- this . storageService . store ( Storage . PANEL_SIZE_BEFORE_MAXIMIZED , this . state . panel . sizeBeforeMaximize , StorageScope . GLOBAL ) ;
10751081 this . setEditorHidden ( true ) ;
10761082 } else {
10771083 this . setEditorHidden ( false ) ;
1078- this . workbenchGrid . resizeView ( this . panelPartView , { width : this . state . panel . position === Position . BOTTOM ? size . width : this . state . panel . sizeBeforeMaximize , height : this . state . panel . position === Position . BOTTOM ? this . state . panel . sizeBeforeMaximize : size . height } ) ;
1084+ this . workbenchGrid . resizeView ( this . panelPartView , { width : this . state . panel . position === Position . BOTTOM ? size . width : this . state . panel . lastNonMaximizedWidth , height : this . state . panel . position === Position . BOTTOM ? this . state . panel . lastNonMaximizedHeight : size . height } ) ;
10791085 }
10801086 }
10811087
@@ -1128,6 +1134,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
11281134 }
11291135 }
11301136
1137+ // Save panel position
11311138 this . storageService . store ( Storage . PANEL_POSITION , positionToString ( this . state . panel . position ) , StorageScope . WORKSPACE ) ;
11321139
11331140 // Adjust CSS
@@ -1141,10 +1148,23 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
11411148 const size = this . workbenchGrid . getViewSize ( this . panelPartView ) ;
11421149 const sideBarSize = this . workbenchGrid . getViewSize ( this . sideBarPartView ) ;
11431150
1151+ // Save last non-maximized size for panel before move
1152+ if ( newPositionValue !== oldPositionValue && ! this . state . editor . hidden ) {
1153+
1154+ // Save the current size of the panel for the new orthogonal direction
1155+ // If moving down, save the width of the panel
1156+ // Otherwise, save the height of the panel
1157+ if ( position === Position . BOTTOM ) {
1158+ this . state . panel . lastNonMaximizedWidth = size . width ;
1159+ } else {
1160+ this . state . panel . lastNonMaximizedHeight = size . height ;
1161+ }
1162+ }
1163+
11441164 if ( position === Position . BOTTOM ) {
1145- this . workbenchGrid . moveView ( this . panelPartView , this . state . editor . hidden ? size . height : size . width , this . editorPartView , Direction . Down ) ;
1165+ this . workbenchGrid . moveView ( this . panelPartView , this . state . editor . hidden ? size . height : this . state . panel . lastNonMaximizedHeight , this . editorPartView , Direction . Down ) ;
11461166 } else {
1147- this . workbenchGrid . moveView ( this . panelPartView , this . state . editor . hidden ? size . width : size . height , this . editorPartView , Direction . Right ) ;
1167+ this . workbenchGrid . moveView ( this . panelPartView , this . state . editor . hidden ? size . width : this . state . panel . lastNonMaximizedWidth , this . editorPartView , Direction . Right ) ;
11481168 }
11491169
11501170 // Reset sidebar to original size before shifting the panel
@@ -1192,7 +1212,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
11921212 const panelNode : ISerializedLeafNode = {
11931213 type : 'leaf' ,
11941214 data : { type : Parts . PANEL_PART } ,
1195- size : wasEditorHidden ? this . state . panel . sizeBeforeMaximize : panelSize ,
1215+ size : wasEditorHidden ? ( this . state . panel . position === Position . BOTTOM ? this . state . panel . lastNonMaximizedHeight : this . state . panel . lastNonMaximizedWidth ) : panelSize ,
11961216 visible : ! this . state . panel . hidden
11971217 } ;
11981218
0 commit comments