@@ -20,6 +20,7 @@ import { DocumentHighlightProviderRegistry } from 'vs/editor/common/modes';
20
20
import { RunOnceScheduler , Delayer } from 'vs/base/common/async' ;
21
21
import { CursorChangeReason , ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents' ;
22
22
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys' ;
23
+ import { IStorageService , StorageScope } from 'vs/platform/storage/common/storage' ;
23
24
24
25
export const enum FindStartFocusAction {
25
26
NoFocusChange ,
@@ -48,19 +49,22 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
48
49
private _currentHistoryNavigator : HistoryNavigator < string > ;
49
50
protected _updateHistoryDelayer : Delayer < void > ;
50
51
private _model : FindModelBoundToEditorModel ;
52
+ private _storageService : IStorageService ;
51
53
52
54
public static get ( editor : editorCommon . ICommonCodeEditor ) : CommonFindController {
53
55
return editor . getContribution < CommonFindController > ( CommonFindController . ID ) ;
54
56
}
55
57
56
- constructor ( editor : editorCommon . ICommonCodeEditor , @IContextKeyService contextKeyService : IContextKeyService ) {
58
+ constructor ( editor : editorCommon . ICommonCodeEditor , @IContextKeyService contextKeyService : IContextKeyService , @ IStorageService storageService : IStorageService ) {
57
59
super ( ) ;
58
60
this . _editor = editor ;
59
61
this . _findWidgetVisible = CONTEXT_FIND_WIDGET_VISIBLE . bindTo ( contextKeyService ) ;
62
+ this . _storageService = storageService ;
60
63
61
64
this . _updateHistoryDelayer = new Delayer < void > ( 500 ) ;
62
65
this . _currentHistoryNavigator = new HistoryNavigator < string > ( ) ;
63
66
this . _state = this . _register ( new FindReplaceState ( ) ) ;
67
+ this . loadQueryState ( ) ;
64
68
this . _register ( this . _state . addChangeListener ( ( e ) => this . _onStateChanged ( e ) ) ) ;
65
69
66
70
this . _model = null ;
@@ -71,7 +75,10 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
71
75
this . disposeModel ( ) ;
72
76
73
77
this . _state . change ( {
74
- searchScope : null
78
+ searchScope : null ,
79
+ matchCase : this . _storageService . getBoolean ( 'editor.matchCase' , StorageScope . WORKSPACE , false ) ,
80
+ wholeWord : this . _storageService . getBoolean ( 'editor.wholeWord' , StorageScope . WORKSPACE , false ) ,
81
+ isRegex : this . _storageService . getBoolean ( 'editor.isRegex' , StorageScope . WORKSPACE , false )
75
82
} , false ) ;
76
83
77
84
if ( shouldRestartFind ) {
@@ -102,6 +109,8 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
102
109
}
103
110
104
111
private _onStateChanged ( e : FindReplaceStateChangedEvent ) : void {
112
+ this . saveQueryState ( e ) ;
113
+
105
114
if ( e . updateHistory && e . searchString ) {
106
115
this . _delayedUpdateHistory ( ) ;
107
116
}
@@ -115,6 +124,26 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
115
124
}
116
125
}
117
126
127
+ private saveQueryState ( e : FindReplaceStateChangedEvent ) {
128
+ if ( e . isRegex && typeof this . _state . isRegex !== 'undefined' ) {
129
+ this . _storageService . store ( 'editor.isRegex' , this . _state . isRegex , StorageScope . WORKSPACE ) ;
130
+ }
131
+ if ( e . wholeWord && typeof this . _state . wholeWord !== 'undefined' ) {
132
+ this . _storageService . store ( 'editor.wholeWord' , this . _state . wholeWord , StorageScope . WORKSPACE ) ;
133
+ }
134
+ if ( e . matchCase && typeof this . _state . matchCase !== 'undefined' ) {
135
+ this . _storageService . store ( 'editor.matchCase' , this . _state . matchCase , StorageScope . WORKSPACE ) ;
136
+ }
137
+ }
138
+
139
+ private loadQueryState ( ) {
140
+ this . _state . change ( {
141
+ matchCase : this . _storageService . getBoolean ( 'editor.matchCase' , StorageScope . WORKSPACE , this . _state . matchCase ) ,
142
+ wholeWord : this . _storageService . getBoolean ( 'editor.wholeWord' , StorageScope . WORKSPACE , this . _state . wholeWord ) ,
143
+ isRegex : this . _storageService . getBoolean ( 'editor.isRegex' , StorageScope . WORKSPACE , this . _state . isRegex )
144
+ } , false ) ;
145
+ }
146
+
118
147
protected _delayedUpdateHistory ( ) {
119
148
this . _updateHistoryDelayer . trigger ( this . _updateHistory . bind ( this ) ) ;
120
149
}
0 commit comments