chore(code/find): reimplement replace all

This commit is contained in:
Elian Doran
2025-05-13 09:42:31 +03:00
parent b646475018
commit 3ace3d9ed9
3 changed files with 17 additions and 17 deletions

View File

@@ -57,6 +57,18 @@ export class SearchHighlighter {
});
}
replaceAll(replacementText: string) {
if (!this.parsedMatches.length) return;
this.view.dispatch({
changes: this.parsedMatches.map(change => ({
from: change.from,
to: change.to,
insert: replacementText
}))
});
}
scrollToMatch(matchIndex: number) {
if (this.parsedMatches.length <= matchIndex) {
return;

View File

@@ -198,6 +198,10 @@ export default class CodeMirror extends EditorView {
this.searchPlugin?.replaceActiveMatch(replaceText);
}
async replaceAll(replaceText: string) {
this.searchPlugin?.replaceAll(replaceText);
}
cleanSearch() {
if (this.searchPlugin) {
this.dispatch({