mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 19:05:59 +01:00
chore(code/find): reimplement single replace
This commit is contained in:
@@ -46,6 +46,17 @@ export class SearchHighlighter {
|
||||
this.#scrollToMatchNearestSelection();
|
||||
}
|
||||
|
||||
replaceActiveMatch(replacementText: string) {
|
||||
if (!this.parsedMatches.length || this.currentFound === 0) return;
|
||||
|
||||
const matchIndex = this.currentFound - 1;
|
||||
const match = this.parsedMatches[matchIndex];
|
||||
|
||||
this.view.dispatch({
|
||||
changes: { from: match.from, to: match.to, insert: replacementText }
|
||||
});
|
||||
}
|
||||
|
||||
scrollToMatch(matchIndex: number) {
|
||||
if (this.parsedMatches.length <= matchIndex) {
|
||||
return;
|
||||
|
||||
@@ -194,6 +194,10 @@ export default class CodeMirror extends EditorView {
|
||||
this.searchPlugin?.scrollToMatch(nextFound);
|
||||
}
|
||||
|
||||
async replace(replaceText: string) {
|
||||
this.searchPlugin?.replaceActiveMatch(replaceText);
|
||||
}
|
||||
|
||||
cleanSearch() {
|
||||
if (this.searchPlugin) {
|
||||
this.dispatch({
|
||||
|
||||
Reference in New Issue
Block a user