mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 10:40:41 +01:00
chore(code/find): reimplement replace all
This commit is contained in:
@@ -61,23 +61,7 @@ export default class FindInCode {
|
||||
}
|
||||
|
||||
async replaceAll(replaceText: string) {
|
||||
if (!this.findResult || this.findResult.length === 0) {
|
||||
return;
|
||||
}
|
||||
const codeEditor = await this.getCodeEditor();
|
||||
const doc = codeEditor?.doc;
|
||||
codeEditor?.operation(() => {
|
||||
if (!this.findResult) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let currentFound = 0; currentFound < this.findResult.length; currentFound++) {
|
||||
let marker = this.findResult[currentFound];
|
||||
let pos = marker.find();
|
||||
doc?.replaceRange(replaceText, pos.from, pos.to);
|
||||
marker.clear();
|
||||
}
|
||||
});
|
||||
this.findResult = [];
|
||||
codeEditor?.replaceAll(replaceText);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user