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 hangup on highlighting empty tokens, closes #3772
zadam9881e6de3e49
diff --git a/src/services/search/services/search.js b/src/services/search/services/search.jsindex beb0555d15..d682af0902 100644--- a/src/services/search/services/search.js+++ b/src/services/search/services/search.js@@ -299,7 +299,9 @@ function highlightSearchResults(searchResults, highlightedTokens) {// which would make the resulting HTML string invalid.// { and } are used for marking <b> and </b> tag (to avoid matches on single 'b' character)// < and > are used for marking <small> and </small>- highlightedTokens = highlightedTokens.map(token => token.replace('/[<\{\}]/g', ''));+ highlightedTokens = highlightedTokens+ .map(token => token.replace('/[<\{\}]/g', ''))+ .filter(token => !!token?.trim());// sort by the longest, so we first highlight the longest matcheshighlightedTokens.sort((a, b) => a.length > b.length ? -1 : 1);