@@ -51,6 +51,7 @@ import { IViewDescriptorService } from 'vs/workbench/common/views';
5151import { IOpenerService } from 'vs/platform/opener/common/opener' ;
5252import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
5353import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
54+ import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys' ;
5455
5556class RequestState {
5657
@@ -176,6 +177,13 @@ class OutlineViewState {
176177 private readonly _onDidChange = new Emitter < { followCursor ?: boolean , sortBy ?: boolean , filterOnType ?: boolean } > ( ) ;
177178 readonly onDidChange = this . _onDidChange . event ;
178179
180+ constructor (
181+ @IStorageService private readonly _storageService : IStorageService ,
182+ @IStorageKeysSyncRegistryService storageKeysSyncService : IStorageKeysSyncRegistryService
183+ ) {
184+ storageKeysSyncService . registerStorageKey ( { key : 'outline/state' , version : 1 } ) ;
185+ }
186+
179187 set followCursor ( value : boolean ) {
180188 if ( value !== this . _followCursor ) {
181189 this . _followCursor = value ;
@@ -209,16 +217,16 @@ class OutlineViewState {
209217 return this . _sortBy ;
210218 }
211219
212- persist ( storageService : IStorageService ) : void {
213- storageService . store ( 'outline/state' , JSON . stringify ( {
220+ persist ( ) : void {
221+ this . _storageService . store ( 'outline/state' , JSON . stringify ( {
214222 followCursor : this . followCursor ,
215223 sortBy : this . sortBy ,
216224 filterOnType : this . filterOnType ,
217225 } ) , StorageScope . WORKSPACE ) ;
218226 }
219227
220- restore ( storageService : IStorageService ) : void {
221- let raw = storageService . get ( 'outline/state' , StorageScope . WORKSPACE ) ;
228+ restore ( ) : void {
229+ let raw = this . _storageService . get ( 'outline/state' , StorageScope . WORKSPACE ) ;
222230 if ( ! raw ) {
223231 return ;
224232 }
@@ -241,7 +249,7 @@ export class OutlinePane extends ViewPane {
241249 private _disposables = new Array < IDisposable > ( ) ;
242250
243251 private _editorDisposables = new DisposableStore ( ) ;
244- private _outlineViewState = new OutlineViewState ( ) ;
252+ private _outlineViewState : OutlineViewState ;
245253 private _requestOracle ?: RequestOracle ;
246254 private _domNode ! : HTMLElement ;
247255 private _message ! : HTMLDivElement ;
@@ -262,7 +270,6 @@ export class OutlinePane extends ViewPane {
262270 @IInstantiationService private readonly _instantiationService : IInstantiationService ,
263271 @IViewDescriptorService viewDescriptorService : IViewDescriptorService ,
264272 @IThemeService private readonly _themeService : IThemeService ,
265- @IStorageService private readonly _storageService : IStorageService ,
266273 @ICodeEditorService private readonly _editorService : ICodeEditorService ,
267274 @IMarkerDecorationsService private readonly _markerDecorationService : IMarkerDecorationsService ,
268275 @IConfigurationService private readonly _configurationService : IConfigurationService ,
@@ -274,7 +281,7 @@ export class OutlinePane extends ViewPane {
274281 @ITelemetryService telemetryService : ITelemetryService ,
275282 ) {
276283 super ( options , keybindingService , contextMenuService , _configurationService , contextKeyService , viewDescriptorService , _instantiationService , openerService , themeService , telemetryService ) ;
277- this . _outlineViewState . restore ( this . _storageService ) ;
284+ this . _outlineViewState = this . instantiationService . createInstance ( OutlineViewState ) ;
278285 this . _contextKeyFocused = OutlineViewFocused . bindTo ( contextKeyService ) ;
279286 this . _contextKeyFiltered = OutlineViewFiltered . bindTo ( contextKeyService ) ;
280287 this . _disposables . push ( this . onDidFocus ( _ => this . _contextKeyFocused . set ( true ) ) ) ;
@@ -434,7 +441,7 @@ export class OutlinePane extends ViewPane {
434441 }
435442
436443 private _onDidChangeUserState ( e : { followCursor ?: boolean , sortBy ?: boolean , filterOnType ?: boolean } ) {
437- this . _outlineViewState . persist ( this . _storageService ) ;
444+ this . _outlineViewState . persist ( ) ;
438445 if ( e . followCursor ) {
439446 // todo@joh update immediately
440447 }
0 commit comments