Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(code/find): reintroduce total number of results
Elian Doranf2745d546ba8
diff --git a/apps/client/src/widgets/find_in_code.ts b/apps/client/src/widgets/find_in_code.tsindex 99d6a335f4..343ce07372 100644--- a/apps/client/src/widgets/find_in_code.ts+++ b/apps/client/src/widgets/find_in_code.ts@@ -31,7 +31,7 @@ export default class FindInCode {}async performFind(searchTerm: string, matchCase: boolean, wholeWord: boolean) {- const totalFound = 0;+ let totalFound = 0;const currentFound = 0;const codeEditor = await this.getCodeEditor();@@ -39,7 +39,8 @@ export default class FindInCode {return { totalFound, currentFound };}- await codeEditor.performFind(searchTerm, matchCase, wholeWord);+ const result = await codeEditor.performFind(searchTerm, matchCase, wholeWord);+ totalFound = result.totalFound;return { totalFound, currentFound };}diff --git a/packages/codemirror/src/find_replace.ts b/packages/codemirror/src/find_replace.tsindex 5b1ead702d..c0687493fc 100644--- a/packages/codemirror/src/find_replace.ts+++ b/packages/codemirror/src/find_replace.ts@@ -17,6 +17,7 @@ export function createSearchHighlighter(view: EditorView, searchTerm: string, mareturn ViewPlugin.fromClass(class SearchHighlighter {matches = matcher.createDeco(view);+ totalFound = this.matches.size;constructor(public view: EditorView) { }@@ -32,7 +33,8 @@ export function createSearchHighlighter(view: EditorView, searchTerm: string, mastatic deco = (v: SearchHighlighter) => v.matches;}, {- decorations: v => v.matches+ decorations: v => v.matches,+ provide: (plugin) => plugin});}diff --git a/packages/codemirror/src/index.ts b/packages/codemirror/src/index.tsindex 86f5e3e35c..b22d4ecc1e 100644--- a/packages/codemirror/src/index.ts+++ b/packages/codemirror/src/index.ts@@ -176,6 +176,13 @@ export default class CodeMirror extends EditorView {this.dispatch({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) {