@@ -70,7 +70,7 @@ import { SearchWidget } from 'vs/workbench/contrib/search/browser/searchWidget';
70
70
import * as Constants from 'vs/workbench/contrib/search/common/constants' ;
71
71
import { IReplaceService } from 'vs/workbench/contrib/search/browser/replace' ;
72
72
import { getOutOfWorkspaceEditorResources , SearchStateKey , SearchUIState } from 'vs/workbench/contrib/search/common/search' ;
73
- import { ISearchHistoryService , ISearchHistoryValues } from 'vs/workbench/contrib/search/common/searchHistoryService' ;
73
+ import { ISearchHistoryService , ISearchHistoryValues , SearchHistoryService } from 'vs/workbench/contrib/search/common/searchHistoryService' ;
74
74
import { FileMatch , FileMatchOrMatch , FolderMatch , FolderMatchWithResource , IChangeEvent , ISearchWorkbenchService , Match , MatchInNotebook , RenderableMatch , searchMatchComparer , SearchModel , SearchResult } from 'vs/workbench/contrib/search/browser/searchModel' ;
75
75
import { createEditorFromSearchResult } from 'vs/workbench/contrib/searchEditor/browser/searchEditorActions' ;
76
76
import { ACTIVE_GROUP , IEditorService , SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService' ;
@@ -185,7 +185,7 @@ export class SearchView extends ViewPane {
185
185
@IContextMenuService contextMenuService : IContextMenuService ,
186
186
@IAccessibilityService private readonly accessibilityService : IAccessibilityService ,
187
187
@IKeybindingService keybindingService : IKeybindingService ,
188
- @IStorageService storageService : IStorageService ,
188
+ @IStorageService private readonly storageService : IStorageService ,
189
189
@IOpenerService openerService : IOpenerService ,
190
190
@ITelemetryService telemetryService : ITelemetryService ,
191
191
@INotebookService private readonly notebookService : INotebookService ,
@@ -257,6 +257,30 @@ export class SearchView extends ViewPane {
257
257
this . isTreeLayoutViewVisible = this . viewletState [ 'view.treeLayout' ] ?? ( this . searchConfig . defaultViewMode === ViewMode . Tree ) ;
258
258
259
259
this . _refreshResultsScheduler = this . _register ( new RunOnceScheduler ( this . _updateResults . bind ( this ) , 80 ) ) ;
260
+
261
+ // storage service listener for for roaming changes
262
+ this . _register ( this . storageService . onWillSaveState ( ( ) => {
263
+ this . _saveSearchHistoryService ( ) ;
264
+ } ) ) ;
265
+
266
+ this . _register ( this . storageService . onDidChangeValue ( ( v ) => {
267
+ if ( v . key === SearchHistoryService . SEARCH_HISTORY_KEY ) {
268
+ const restoredHistory = this . searchHistoryService . load ( ) ;
269
+
270
+ if ( restoredHistory . include ) {
271
+ this . inputPatternIncludes . prependHistory ( restoredHistory . include ) ;
272
+ }
273
+ if ( restoredHistory . exclude ) {
274
+ this . inputPatternExcludes . prependHistory ( restoredHistory . exclude ) ;
275
+ }
276
+ if ( restoredHistory . search ) {
277
+ this . searchWidget . prependSearchHistory ( restoredHistory . search ) ;
278
+ }
279
+ if ( restoredHistory . replace ) {
280
+ this . searchWidget . prependReplaceHistory ( restoredHistory . replace ) ;
281
+ }
282
+ }
283
+ } ) ) ;
260
284
}
261
285
262
286
get isTreeLayoutViewVisible ( ) : boolean {
@@ -2038,6 +2062,14 @@ export class SearchView extends ViewPane {
2038
2062
this . viewletState [ 'view.treeLayout' ] = this . isTreeLayoutViewVisible ;
2039
2063
this . viewletState [ 'query.replaceText' ] = isReplaceShown && this . searchWidget . getReplaceValue ( ) ;
2040
2064
2065
+ this . _saveSearchHistoryService ( ) ;
2066
+
2067
+ this . memento . saveMemento ( ) ;
2068
+
2069
+ super . saveState ( ) ;
2070
+ }
2071
+
2072
+ private _saveSearchHistoryService ( ) {
2041
2073
const history : ISearchHistoryValues = Object . create ( null ) ;
2042
2074
2043
2075
const searchHistory = this . searchWidget . getSearchHistory ( ) ;
@@ -2061,10 +2093,6 @@ export class SearchView extends ViewPane {
2061
2093
}
2062
2094
2063
2095
this . searchHistoryService . save ( history ) ;
2064
-
2065
- this . memento . saveMemento ( ) ;
2066
-
2067
- super . saveState ( ) ;
2068
2096
}
2069
2097
2070
2098
private async retrieveFileStats ( ) : Promise < void > {
0 commit comments