mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
chore(code/find): reintroduce total number of results
This commit is contained in:
parent
749ae1b6b4
commit
f2745d546b
@ -31,7 +31,7 @@ export default class FindInCode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async performFind(searchTerm: string, matchCase: boolean, wholeWord: boolean) {
|
async performFind(searchTerm: string, matchCase: boolean, wholeWord: boolean) {
|
||||||
const totalFound = 0;
|
let totalFound = 0;
|
||||||
const currentFound = 0;
|
const currentFound = 0;
|
||||||
|
|
||||||
const codeEditor = await this.getCodeEditor();
|
const codeEditor = await this.getCodeEditor();
|
||||||
@ -39,7 +39,8 @@ export default class FindInCode {
|
|||||||
return { totalFound, currentFound };
|
return { totalFound, currentFound };
|
||||||
}
|
}
|
||||||
|
|
||||||
await codeEditor.performFind(searchTerm, matchCase, wholeWord);
|
const result = await codeEditor.performFind(searchTerm, matchCase, wholeWord);
|
||||||
|
totalFound = result.totalFound;
|
||||||
|
|
||||||
return { totalFound, currentFound };
|
return { totalFound, currentFound };
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ export function createSearchHighlighter(view: EditorView, searchTerm: string, ma
|
|||||||
|
|
||||||
return ViewPlugin.fromClass(class SearchHighlighter {
|
return ViewPlugin.fromClass(class SearchHighlighter {
|
||||||
matches = matcher.createDeco(view);
|
matches = matcher.createDeco(view);
|
||||||
|
totalFound = this.matches.size;
|
||||||
|
|
||||||
constructor(public view: EditorView) { }
|
constructor(public view: EditorView) { }
|
||||||
|
|
||||||
@ -32,7 +33,8 @@ export function createSearchHighlighter(view: EditorView, searchTerm: string, ma
|
|||||||
|
|
||||||
static deco = (v: SearchHighlighter) => v.matches;
|
static deco = (v: SearchHighlighter) => v.matches;
|
||||||
}, {
|
}, {
|
||||||
decorations: v => v.matches
|
decorations: v => v.matches,
|
||||||
|
provide: (plugin) => plugin
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,6 +176,13 @@ export default class CodeMirror extends EditorView {
|
|||||||
this.dispatch({
|
this.dispatch({
|
||||||
effects: this.searchHighlightCompartment.reconfigure(plugin)
|
effects: this.searchHighlightCompartment.reconfigure(plugin)
|
||||||
});
|
});
|
||||||
|
// Wait for the plugin to activate in the next render cycle
|
||||||
|
await new Promise(requestAnimationFrame);
|
||||||
|
const instance = this.plugin(plugin); // TS workaround
|
||||||
|
|
||||||
|
return {
|
||||||
|
totalFound: instance?.totalFound ?? 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setMimeType(mime: string) {
|
async setMimeType(mime: string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user