@@ -25,7 +25,6 @@ import { SidebarPart } from 'vs/workbench/browser/parts/sidebar/sidebarPart';
2525import { PanelPart } from 'vs/workbench/browser/parts/panel/panelPart' ;
2626import { StatusbarPart } from 'vs/workbench/browser/parts/statusbar/statusbarPart' ;
2727import { getZoomFactor } from 'vs/base/browser/browser' ;
28- import { RunOnceScheduler } from 'vs/base/common/async' ;
2928import * as perf from 'vs/base/common/performance' ;
3029
3130const TITLE_BAR_HEIGHT = isMacintosh ? 22 : 30 ;
@@ -69,8 +68,6 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
6968 private _panelHeight : number ;
7069 private _panelWidth : number ;
7170
72- private saveStateScheduler : RunOnceScheduler ;
73-
7471 constructor (
7572 private parent : HTMLElement ,
7673 private workbenchContainer : HTMLElement ,
@@ -103,9 +100,6 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
103100 this . sashXTwo = new Sash ( this . workbenchContainer , this ) ;
104101 this . sashY = new Sash ( this . workbenchContainer , this , { orientation : Orientation . HORIZONTAL } ) ;
105102
106- // State scheduler
107- this . saveStateScheduler = this . _register ( new RunOnceScheduler ( ( ) => this . saveState ( ) , 800 ) ) ;
108-
109103 this . registerListeners ( ) ;
110104 }
111105
@@ -122,10 +116,6 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
122116 private registerListeners ( ) : void {
123117 this . _register ( this . themeService . onThemeChange ( _ => this . layout ( ) ) ) ;
124118 this . _register ( this . parts . editor . onDidSizeConstraintsChange ( ( ) => this . onDidEditorSizeConstraintsChange ( ) ) ) ;
125- this . _register ( this . storageService . onWillSaveState ( ( ) => {
126- this . saveStateScheduler . dispose ( ) ;
127- this . saveState ( ) ;
128- } ) ) ;
129119
130120 this . registerSashListeners ( ) ;
131121 }
@@ -383,21 +373,20 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
383373 } ) ) ;
384374
385375 this . _register ( this . sashXOne . onDidEnd ( ( ) => {
386- this . saveStateScheduler . schedule ( ) ;
376+ this . storageService . store ( WorkbenchLayout . sashXOneWidthSettingsKey , this . sidebarWidth , StorageScope . GLOBAL ) ;
387377 } ) ) ;
388378
389379 this . _register ( this . sashY . onDidEnd ( ( ) => {
390- this . saveStateScheduler . schedule ( ) ;
380+ this . storageService . store ( WorkbenchLayout . sashYHeightSettingsKey , this . panelHeight , StorageScope . GLOBAL ) ;
391381 } ) ) ;
392382
393383 this . _register ( this . sashXTwo . onDidEnd ( ( ) => {
394- this . saveStateScheduler . schedule ( ) ;
384+ this . storageService . store ( WorkbenchLayout . sashXTwoWidthSettingsKey , this . panelWidth , StorageScope . GLOBAL ) ;
395385 } ) ) ;
396386
397387 this . _register ( this . sashY . onDidReset ( ( ) => {
398388 this . panelHeight = this . sidebarHeight * DEFAULT_PANEL_SIZE_COEFFICIENT ;
399-
400- this . saveStateScheduler . schedule ( ) ;
389+ this . storageService . store ( WorkbenchLayout . sashYHeightSettingsKey , this . panelHeight , StorageScope . GLOBAL ) ;
401390
402391 this . layout ( ) ;
403392 } ) ) ;
@@ -406,22 +395,20 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
406395 let activeViewlet = this . viewletService . getActiveViewlet ( ) ;
407396 let optimalWidth = activeViewlet && activeViewlet . getOptimalWidth ( ) ;
408397 this . sidebarWidth = Math . max ( optimalWidth , DEFAULT_SIDEBAR_PART_WIDTH ) ;
409-
410- this . saveStateScheduler . schedule ( ) ;
398+ this . storageService . store ( WorkbenchLayout . sashXOneWidthSettingsKey , this . sidebarWidth , StorageScope . GLOBAL ) ;
411399
412400 this . partService . setSideBarHidden ( false ) . then ( ( ) => this . layout ( ) ) ;
413401 } ) ) ;
414402
415403 this . _register ( this . sashXTwo . onDidReset ( ( ) => {
416404 this . panelWidth = ( this . workbenchSize . width - this . sidebarWidth - this . activitybarWidth ) * DEFAULT_PANEL_SIZE_COEFFICIENT ;
417-
418- this . saveStateScheduler . schedule ( ) ;
405+ this . storageService . store ( WorkbenchLayout . sashXTwoWidthSettingsKey , this . panelWidth , StorageScope . GLOBAL ) ;
419406
420407 this . layout ( ) ;
421408 } ) ) ;
422409 }
423410
424- layout ( options ?: ILayoutOptions ) : void { //
411+ layout ( options ?: ILayoutOptions ) : void {
425412 this . workbenchSize = getClientArea ( this . parent ) ;
426413
427414 const isActivityBarHidden = ! this . partService . isVisible ( Parts . ACTIVITYBAR_PART ) ;
@@ -490,6 +477,8 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
490477 }
491478 }
492479
480+ this . storageService . store ( WorkbenchLayout . panelSizeBeforeMaximizedKey , this . panelSizeBeforeMaximized , StorageScope . GLOBAL ) ;
481+
493482 const panelDimension = new Dimension ( panelWidth , panelHeight ) ;
494483
495484 // Editor
@@ -544,13 +533,16 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
544533
545534 if ( ! isSidebarHidden ) {
546535 this . sidebarWidth = sidebarSize . width ;
536+ this . storageService . store ( WorkbenchLayout . sashXOneWidthSettingsKey , this . sidebarWidth , StorageScope . GLOBAL ) ;
547537 }
548538
549539 if ( ! isPanelHidden ) {
550540 if ( panelPosition === Position . BOTTOM ) {
551541 this . panelHeight = panelDimension . height ;
542+ this . storageService . store ( WorkbenchLayout . sashYHeightSettingsKey , this . panelHeight , StorageScope . GLOBAL ) ;
552543 } else {
553544 this . panelWidth = panelDimension . width ;
545+ this . storageService . store ( WorkbenchLayout . sashXTwoWidthSettingsKey , this . panelWidth , StorageScope . GLOBAL ) ;
554546 }
555547 }
556548
@@ -670,9 +662,6 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
670662
671663 // Propagate to Context View
672664 this . contextViewService . layout ( ) ;
673-
674- // Schedule save state
675- this . saveStateScheduler . schedule ( ) ;
676665 }
677666
678667 getVerticalSashTop ( sash : Sash ) : number {
@@ -774,13 +763,4 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
774763 this . layout ( ) ;
775764 }
776765 }
777-
778- private saveState ( ) : void {
779- this . storageService . store ( WorkbenchLayout . sashXOneWidthSettingsKey , this . sidebarWidth , StorageScope . GLOBAL ) ;
780-
781- this . storageService . store ( WorkbenchLayout . sashYHeightSettingsKey , this . panelHeight , StorageScope . GLOBAL ) ;
782- this . storageService . store ( WorkbenchLayout . sashXTwoWidthSettingsKey , this . panelWidth , StorageScope . GLOBAL ) ;
783-
784- this . storageService . store ( WorkbenchLayout . panelSizeBeforeMaximizedKey , this . panelSizeBeforeMaximized , StorageScope . GLOBAL ) ;
785- }
786766}
0 commit comments