@@ -37,7 +37,7 @@ import { QuickInputService } from 'vs/workbench/browser/parts/quickinput/quickIn
3737import { getServices } from 'vs/platform/instantiation/common/extensions' ;
3838import { Position , Parts , IPartService , ILayoutOptions , IDimension , PositionToString } from 'vs/workbench/services/part/common/partService' ;
3939import { IWorkspaceContextService , WorkbenchState } from 'vs/platform/workspace/common/workspace' ;
40- import { IStorageService , StorageScope } from 'vs/platform/storage /common/storage ' ;
40+ import { INextStorage2Service , StorageScope } from 'vs/platform/storage2 /common/storage2 ' ;
4141import { ContextMenuService as NativeContextMenuService } from 'vs/workbench/services/contextview/electron-browser/contextmenuService' ;
4242import { ContextMenuService as HTMLContextMenuService } from 'vs/platform/contextview/browser/contextMenuService' ;
4343import { WorkbenchKeybindingService } from 'vs/workbench/services/keybinding/electron-browser/keybindingService' ;
@@ -239,7 +239,7 @@ export class Workbench extends Disposable implements IPartService {
239239 private mainProcessClient : IPCClient ,
240240 @IInstantiationService private instantiationService : IInstantiationService ,
241241 @IWorkspaceContextService private contextService : IWorkspaceContextService ,
242- @IStorageService private storageService : IStorageService ,
242+ @INextStorage2Service private nextStorage2Service : INextStorage2Service ,
243243 @IConfigurationService private configurationService : WorkspaceService ,
244244 @IWorkbenchThemeService private themeService : WorkbenchThemeService ,
245245 @IEnvironmentService private environmentService : IEnvironmentService ,
@@ -483,6 +483,9 @@ export class Workbench extends Disposable implements IPartService {
483483
484484 private registerListeners ( ) : void {
485485
486+ // Storage lifecycle
487+ this . _register ( this . nextStorage2Service . onWillClose ( reason => this . saveState ( reason ) ) ) ;
488+
486489 // Listen to visible editor changes
487490 this . _register ( this . editorService . onDidVisibleEditorsChange ( ( ) => this . onDidVisibleEditorsChange ( ) ) ) ;
488491
@@ -738,7 +741,7 @@ export class Workbench extends Disposable implements IPartService {
738741 this . sideBarVisibleContext . set ( true ) ;
739742
740743 if ( this . shouldRestoreLastOpenedViewlet ( ) ) {
741- viewletIdToRestore = this . storageService . get ( SidebarPart . activeViewletSettingsKey , StorageScope . WORKSPACE ) ;
744+ viewletIdToRestore = this . nextStorage2Service . get ( SidebarPart . activeViewletSettingsKey , StorageScope . WORKSPACE ) ;
742745 }
743746
744747 if ( ! viewletIdToRestore ) {
@@ -755,7 +758,7 @@ export class Workbench extends Disposable implements IPartService {
755758
756759 // Restore Panel
757760 const panelRegistry = Registry . as < PanelRegistry > ( PanelExtensions . Panels ) ;
758- const panelId = this . storageService . get ( PanelPart . activePanelSettingsKey , StorageScope . WORKSPACE , panelRegistry . getDefaultPanelId ( ) ) ;
761+ const panelId = this . nextStorage2Service . get ( PanelPart . activePanelSettingsKey , StorageScope . WORKSPACE , panelRegistry . getDefaultPanelId ( ) ) ;
759762 if ( ! this . panelHidden && ! ! panelId ) {
760763 perf . mark ( 'willRestorePanel' ) ;
761764 const isPanelToRestoreEnabled = ! ! this . panelPart . getPanels ( ) . filter ( p => p . id === panelId ) . length ;
@@ -764,12 +767,12 @@ export class Workbench extends Disposable implements IPartService {
764767 }
765768
766769 // Restore Zen Mode if active
767- if ( this . storageService . getBoolean ( Workbench . zenModeActiveStorageKey , StorageScope . WORKSPACE , false ) ) {
770+ if ( this . nextStorage2Service . getBoolean ( Workbench . zenModeActiveStorageKey , StorageScope . WORKSPACE , false ) ) {
768771 this . toggleZenMode ( true , true ) ;
769772 }
770773
771774 // Restore Forced Editor Center Mode
772- if ( this . storageService . getBoolean ( Workbench . centeredEditorLayoutActiveStorageKey , StorageScope . WORKSPACE , false ) ) {
775+ if ( this . nextStorage2Service . getBoolean ( Workbench . centeredEditorLayoutActiveStorageKey , StorageScope . WORKSPACE , false ) ) {
773776 this . centerEditorLayout ( true ) ;
774777 }
775778
@@ -796,9 +799,9 @@ export class Workbench extends Disposable implements IPartService {
796799 return true ; // always restore sidebar when we are in development mode
797800 }
798801
799- const restore = this . storageService . getBoolean ( Workbench . sidebarRestoreStorageKey , StorageScope . WORKSPACE ) ;
802+ const restore = this . nextStorage2Service . getBoolean ( Workbench . sidebarRestoreStorageKey , StorageScope . WORKSPACE ) ;
800803 if ( restore ) {
801- this . storageService . remove ( Workbench . sidebarRestoreStorageKey , StorageScope . WORKSPACE ) ; // only support once
804+ this . nextStorage2Service . delete ( Workbench . sidebarRestoreStorageKey , StorageScope . WORKSPACE ) ; // only support once
802805 }
803806
804807 return restore ;
@@ -889,11 +892,11 @@ export class Workbench extends Disposable implements IPartService {
889892 private initSettings ( ) : void {
890893
891894 // Sidebar visibility
892- this . sideBarHidden = this . storageService . getBoolean ( Workbench . sidebarHiddenStorageKey , StorageScope . WORKSPACE , this . contextService . getWorkbenchState ( ) === WorkbenchState . EMPTY ) ;
895+ this . sideBarHidden = this . nextStorage2Service . getBoolean ( Workbench . sidebarHiddenStorageKey , StorageScope . WORKSPACE , this . contextService . getWorkbenchState ( ) === WorkbenchState . EMPTY ) ;
893896
894897 // Panel part visibility
895898 const panelRegistry = Registry . as < PanelRegistry > ( PanelExtensions . Panels ) ;
896- this . panelHidden = this . storageService . getBoolean ( Workbench . panelHiddenStorageKey , StorageScope . WORKSPACE , true ) ;
899+ this . panelHidden = this . nextStorage2Service . getBoolean ( Workbench . panelHiddenStorageKey , StorageScope . WORKSPACE , true ) ;
897900 if ( ! panelRegistry . getDefaultPanelId ( ) ) {
898901 this . panelHidden = true ; // we hide panel part if there is no default panel
899902 }
@@ -933,7 +936,8 @@ export class Workbench extends Disposable implements IPartService {
933936
934937 private setPanelPositionFromStorageOrConfig ( ) {
935938 const defaultPanelPosition = this . configurationService . getValue < string > ( Workbench . defaultPanelPositionStorageKey ) ;
936- const panelPosition = this . storageService . get ( Workbench . panelPositionStorageKey , StorageScope . WORKSPACE , defaultPanelPosition ) ;
939+ const panelPosition = this . nextStorage2Service . get ( Workbench . panelPositionStorageKey , StorageScope . WORKSPACE , defaultPanelPosition ) ;
940+
937941 this . panelPosition = ( panelPosition === 'right' ) ? Position . RIGHT : Position . BOTTOM ;
938942 }
939943
@@ -1132,25 +1136,29 @@ export class Workbench extends Disposable implements IPartService {
11321136 return this . instantiationService ;
11331137 }
11341138
1135- dispose ( reason = ShutdownReason . QUIT ) : void {
1136- super . dispose ( ) ;
1139+ private saveState ( reason : ShutdownReason ) : void {
11371140
11381141 // Restore sidebar if we are being shutdown as a matter of a reload
11391142 if ( reason === ShutdownReason . RELOAD ) {
1140- this . storageService . store ( Workbench . sidebarRestoreStorageKey , 'true' , StorageScope . WORKSPACE ) ;
1143+ this . nextStorage2Service . set ( Workbench . sidebarRestoreStorageKey , 'true' , StorageScope . WORKSPACE ) ;
11411144 }
11421145
11431146 // Preserve zen mode only on reload. Real quit gets out of zen mode so novice users do not get stuck in zen mode.
11441147 const zenConfig = this . configurationService . getValue < IZenModeSettings > ( 'zenMode' ) ;
11451148 const restoreZenMode = this . zenMode . active && ( zenConfig . restore || reason === ShutdownReason . RELOAD ) ;
11461149 if ( restoreZenMode ) {
1147- this . storageService . store ( Workbench . zenModeActiveStorageKey , true , StorageScope . WORKSPACE ) ;
1150+ this . nextStorage2Service . set ( Workbench . zenModeActiveStorageKey , true , StorageScope . WORKSPACE ) ;
11481151 } else {
11491152 if ( this . zenMode . active ) {
11501153 this . toggleZenMode ( true ) ;
11511154 }
1152- this . storageService . remove ( Workbench . zenModeActiveStorageKey , StorageScope . WORKSPACE ) ;
1155+
1156+ this . nextStorage2Service . delete ( Workbench . zenModeActiveStorageKey , StorageScope . WORKSPACE ) ;
11531157 }
1158+ }
1159+
1160+ dispose ( reason = ShutdownReason . QUIT ) : void {
1161+ super . dispose ( ) ;
11541162
11551163 this . workbenchShutdown = true ;
11561164 }
@@ -1331,7 +1339,7 @@ export class Workbench extends Disposable implements IPartService {
13311339 }
13321340
13331341 centerEditorLayout ( active : boolean , skipLayout ?: boolean ) : void {
1334- this . storageService . store ( Workbench . centeredEditorLayoutActiveStorageKey , active , StorageScope . WORKSPACE ) ;
1342+ this . nextStorage2Service . set ( Workbench . centeredEditorLayoutActiveStorageKey , active , StorageScope . WORKSPACE ) ;
13351343 this . shouldCenterLayout = active ;
13361344 let smartActive = active ;
13371345 if ( this . editorPart . groups . length > 1 && this . configurationService . getValue ( 'workbench.editor.centeredLayoutAutoResize' ) ) {
@@ -1410,9 +1418,9 @@ export class Workbench extends Disposable implements IPartService {
14101418 // Remember in settings
14111419 const defaultHidden = this . contextService . getWorkbenchState ( ) === WorkbenchState . EMPTY ;
14121420 if ( hidden !== defaultHidden ) {
1413- this . storageService . store ( Workbench . sidebarHiddenStorageKey , hidden ? 'true' : 'false' , StorageScope . WORKSPACE ) ;
1421+ this . nextStorage2Service . set ( Workbench . sidebarHiddenStorageKey , hidden ? 'true' : 'false' , StorageScope . WORKSPACE ) ;
14141422 } else {
1415- this . storageService . remove ( Workbench . sidebarHiddenStorageKey , StorageScope . WORKSPACE ) ;
1423+ this . nextStorage2Service . delete ( Workbench . sidebarHiddenStorageKey , StorageScope . WORKSPACE ) ;
14161424 }
14171425
14181426 // Layout
@@ -1452,9 +1460,9 @@ export class Workbench extends Disposable implements IPartService {
14521460
14531461 // Remember in settings
14541462 if ( ! hidden ) {
1455- this . storageService . store ( Workbench . panelHiddenStorageKey , 'false' , StorageScope . WORKSPACE ) ;
1463+ this . nextStorage2Service . set ( Workbench . panelHiddenStorageKey , 'false' , StorageScope . WORKSPACE ) ;
14561464 } else {
1457- this . storageService . remove ( Workbench . panelHiddenStorageKey , StorageScope . WORKSPACE ) ;
1465+ this . nextStorage2Service . delete ( Workbench . panelHiddenStorageKey , StorageScope . WORKSPACE ) ;
14581466 }
14591467
14601468 // Layout
@@ -1522,7 +1530,7 @@ export class Workbench extends Disposable implements IPartService {
15221530 const newPositionValue = ( position === Position . BOTTOM ) ? 'bottom' : 'right' ;
15231531 const oldPositionValue = ( this . panelPosition === Position . BOTTOM ) ? 'bottom' : 'right' ;
15241532 this . panelPosition = position ;
1525- this . storageService . store ( Workbench . panelPositionStorageKey , PositionToString ( this . panelPosition ) . toLowerCase ( ) , StorageScope . WORKSPACE ) ;
1533+ this . nextStorage2Service . set ( Workbench . panelPositionStorageKey , PositionToString ( this . panelPosition ) . toLowerCase ( ) , StorageScope . WORKSPACE ) ;
15261534
15271535 // Adjust CSS
15281536 DOM . removeClass ( this . panelPart . getContainer ( ) , oldPositionValue ) ;
0 commit comments