From 61e1427b8327fc56ff62c372308a90284396ed27 Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 26 Nov 2018 22:35:19 +0100 Subject: [PATCH] fix matching of "b" in the note autcomplete highlighter --- src/services/note_cache.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/services/note_cache.js b/src/services/note_cache.js index e19cac5f6..f5581ee74 100644 --- a/src/services/note_cache.js +++ b/src/services/note_cache.js @@ -38,7 +38,8 @@ async function load() { function highlightResults(results, allTokens) { // we remove < signs because they can cause trouble in matching and overwriting existing highlighted chunks // which would make the resulting HTML string invalid. - allTokens = allTokens.map(token => token.replace('/ and tag (to avoid matches on single 'b' character) + allTokens = allTokens.map(token => token.replace('/[<\{\}]/g', '')); // sort by the longest so we first highlight longest matches allTokens.sort((a, b) => a.length > b.length ? -1 : 1); @@ -51,9 +52,15 @@ function highlightResults(results, allTokens) { const tokenRegex = new RegExp("(" + utils.escapeRegExp(token) + ")", "gi"); for (const result of results) { - result.highlighted = result.highlighted.replace(tokenRegex, "$1"); + result.highlighted = result.highlighted.replace(tokenRegex, "{$1}"); } } + + for (const result of results) { + result.highlighted = result.highlighted + .replace(/{/g, "") + .replace(/}/g, ""); + } } function findNotes(query) {