2626define ( function ( require , exports , module ) {
2727
2828 const EventDispatcher = require ( "utils/EventDispatcher" ) ,
29+ PreferencesManager = require ( "preferences/PreferencesManager" ) ,
2930 Resizer = require ( "utils/Resizer" ) ,
3031 Strings = require ( "strings" ) ;
3132
@@ -91,6 +92,9 @@ define(function (require, exports, module) {
9192 */
9293 const MIN_PANEL_HEIGHT = 200 ;
9394
95+ /** Preference key for persisting the maximize state across reloads. */
96+ const PREF_BOTTOM_PANEL_MAXIMIZED = "bottomPanelMaximized" ;
97+
9498 /** @type {number|null } The panel height before maximize, for restore */
9599 let _preMaximizeHeight = null ;
96100
@@ -528,16 +532,24 @@ define(function (require, exports, module) {
528532 _toggleMaximize ( ) ;
529533 } ) ;
530534
531- // When the container re-expands after being minimized, re-apply
532- // maximize if the user had maximized before minimizing.
533- // The Resizer restores the saved (maximized) height automatically,
534- // so we only need to update the button icon and recompute layout.
535+ // Restore maximize state from preferences (survives reload).
536+ _isMaximized = PreferencesManager . getViewState ( PREF_BOTTOM_PANEL_MAXIMIZED ) === true ;
537+
538+ // When the container expands, re-apply maximize if the preference
539+ // says we were maximized (covers both minimize→show and reload).
535540 _$container . on ( "panelExpanded" , function ( ) {
536541 if ( _isMaximized ) {
537- _updateMaximizeButton ( ) ;
538- if ( _recomputeLayout ) {
539- _recomputeLayout ( ) ;
540- }
542+ // Defer to let all synchronous panelExpanded handlers
543+ // (including WorkspaceManager's recomputeLayout) finish first.
544+ setTimeout ( function ( ) {
545+ let maxHeight = ( _$editorHolder ? _$editorHolder . height ( ) : 0 ) +
546+ _$container . height ( ) ;
547+ _$container . height ( maxHeight ) ;
548+ _updateMaximizeButton ( ) ;
549+ if ( _recomputeLayout ) {
550+ _recomputeLayout ( ) ;
551+ }
552+ } , 0 ) ;
541553 }
542554 } ) ;
543555 }
@@ -566,6 +578,7 @@ define(function (require, exports, module) {
566578 let maxHeight = _$editorHolder . height ( ) + _$container . height ( ) ;
567579 _$container . height ( maxHeight ) ;
568580 _isMaximized = true ;
581+ PreferencesManager . setViewState ( PREF_BOTTOM_PANEL_MAXIMIZED , true ) ;
569582 _updateMaximizeButton ( ) ;
570583 if ( _recomputeLayout ) {
571584 _recomputeLayout ( ) ;
@@ -617,6 +630,7 @@ define(function (require, exports, module) {
617630 _$container . height ( restoreHeight ) ;
618631 _isMaximized = false ;
619632 _preMaximizeHeight = null ;
633+ PreferencesManager . setViewState ( PREF_BOTTOM_PANEL_MAXIMIZED , false ) ;
620634 _updateMaximizeButton ( ) ;
621635 if ( _recomputeLayout ) {
622636 _recomputeLayout ( ) ;
@@ -654,6 +668,7 @@ define(function (require, exports, module) {
654668 }
655669 _isMaximized = false ;
656670 _preMaximizeHeight = null ;
671+ PreferencesManager . setViewState ( PREF_BOTTOM_PANEL_MAXIMIZED , false ) ;
657672 _updateMaximizeButton ( ) ;
658673 }
659674
@@ -669,6 +684,7 @@ define(function (require, exports, module) {
669684 }
670685 _isMaximized = true ;
671686 _preMaximizeHeight = null ;
687+ PreferencesManager . setViewState ( PREF_BOTTOM_PANEL_MAXIMIZED , true ) ;
672688 _updateMaximizeButton ( ) ;
673689 }
674690
@@ -689,6 +705,7 @@ define(function (require, exports, module) {
689705 }
690706 _isMaximized = false ;
691707 _preMaximizeHeight = null ;
708+ PreferencesManager . setViewState ( PREF_BOTTOM_PANEL_MAXIMIZED , false ) ;
692709 _updateMaximizeButton ( ) ;
693710 }
694711
0 commit comments