@@ -17,10 +17,16 @@ interface Match {
1717 } ;
1818}
1919
20+ interface SearchParameters {
21+ searchTerm : string ;
22+ matchCase : boolean ;
23+ wholeWord : boolean ;
24+ }
25+
2026export default class FindInCode {
2127
2228 private parent : FindWidget ;
23- private findResult ?: Match [ ] | null ;
29+ private searchParameters : SearchParameters | null = null ;
2430
2531 constructor ( parent : FindWidget ) {
2632 this . parent = parent ;
@@ -36,6 +42,11 @@ export default class FindInCode {
3642 return { totalFound : 0 , currentFound : 0 } ;
3743 }
3844
45+ this . searchParameters = {
46+ searchTerm,
47+ matchCase,
48+ wholeWord,
49+ } ;
3950 const { totalFound, currentFound } = await codeEditor . performFind ( searchTerm , matchCase , wholeWord ) ;
4051 return { totalFound, currentFound } ;
4152 }
@@ -57,11 +68,23 @@ export default class FindInCode {
5768
5869 async replace ( replaceText : string ) {
5970 const codeEditor = await this . getCodeEditor ( ) ;
60- codeEditor ?. replace ( replaceText ) ;
71+ await codeEditor ?. replace ( replaceText ) ;
72+ this . rerunSearch ( ) ;
6173 }
6274
6375 async replaceAll ( replaceText : string ) {
6476 const codeEditor = await this . getCodeEditor ( ) ;
65- codeEditor ?. replaceAll ( replaceText ) ;
77+ await codeEditor ?. replaceAll ( replaceText ) ;
78+ this . rerunSearch ( ) ;
79+ }
80+
81+ private rerunSearch ( ) {
82+ if ( this . searchParameters ) {
83+ this . performFind (
84+ this . searchParameters . searchTerm ,
85+ this . searchParameters . matchCase ,
86+ this . searchParameters . wholeWord ) ;
87+ }
6688 }
89+
6790}
0 commit comments