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
fix(code/find): clean up search
Elian Doran77fe100591a3
diff --git a/apps/client/src/widgets/find_in_code.ts b/apps/client/src/widgets/find_in_code.tsindex a69ddd7581..46131bd4ee 100644--- a/apps/client/src/widgets/find_in_code.ts+++ b/apps/client/src/widgets/find_in_code.ts@@ -51,29 +51,7 @@ export default class FindInCode {async findBoxClosed(totalFound: number, currentFound: number) {const codeEditor = await this.getCodeEditor();-- if (codeEditor && totalFound > 0) {- const doc = codeEditor.doc;- const pos = this.findResult?.[currentFound].find();- // Note setting the selection sets the cursor to- // the end of the selection and scrolls it into- // view- if (pos) {- doc.setSelection(pos.from, pos.to);- }- // Clear all markers- codeEditor.operation(() => {- if (!this.findResult) {- return;- }- for (let i = 0; i < this.findResult.length; ++i) {- let marker = this.findResult[i];- marker.clear();- }- });- }- this.findResult = null;-+ codeEditor?.cleanSearch();codeEditor?.focus();}async replace(replaceText: string) {diff --git a/packages/codemirror/src/index.ts b/packages/codemirror/src/index.tsindex cbf12c2d5b..f41472d257 100644--- a/packages/codemirror/src/index.ts+++ b/packages/codemirror/src/index.ts@@ -194,6 +194,15 @@ export default class CodeMirror extends EditorView {this.searchPlugin?.scrollToMatch(nextFound);}+ cleanSearch() {+ if (this.searchPlugin) {+ this.dispatch({+ effects: this.searchHighlightCompartment.reconfigure([])+ });+ this.searchPlugin = null;+ }+ }+async setMimeType(mime: string) {let newExtension: Extension[] = [];