Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 41f142a

Browse files
committed
feat(code): re-trigger search after replace
1 parent 28aaa28 commit 41f142a

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

apps/client/src/widgets/find_in_code.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@ interface Match {
1717
};
1818
}
1919

20+
interface SearchParameters {
21+
searchTerm: string;
22+
matchCase: boolean;
23+
wholeWord: boolean;
24+
}
25+
2026
export 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

Comments
 (0)