From 5fd58def1145c8f2014321a6febfbe5f8da2c270 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 30 Aug 2020 23:19:55 +0200 Subject: [PATCH] small refactorings --- src/services/search/expressions/note_cache_flat_text.js | 9 ++------- src/services/search/services/search.js | 2 ++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/services/search/expressions/note_cache_flat_text.js b/src/services/search/expressions/note_cache_flat_text.js index 944316140..bbb5cbcea 100644 --- a/src/services/search/expressions/note_cache_flat_text.js +++ b/src/services/search/expressions/note_cache_flat_text.js @@ -87,14 +87,9 @@ class NoteCacheFlatTextExp extends Expression { if (note.type.includes(token) || note.mime.includes(token)) { foundAttrTokens.push(token); } - } - for (const attribute of note.ownedAttributes) { - const lcName = attribute.name.toLowerCase(); - const lcValue = attribute.value.toLowerCase(); - - for (const token of this.tokens) { - if (lcName.includes(token) || lcValue.includes(token)) { + for (const attribute of note.ownedAttributes) { + if (attribute.name.includes(token) || attribute.value.includes(token)) { foundAttrTokens.push(token); } } diff --git a/src/services/search/services/search.js b/src/services/search/services/search.js index 51b45bedd..eb7be931b 100644 --- a/src/services/search/services/search.js +++ b/src/services/search/services/search.js @@ -133,6 +133,8 @@ function searchNotesForAutocomplete(query) { } function highlightSearchResults(searchResults, highlightedTokens) { + highlightedTokens = Array.from(new Set(highlightedTokens)); + // we remove < signs because they can cause trouble in matching and overwriting existing highlighted chunks // which would make the resulting HTML string invalid. // { and } are used for marking and tag (to avoid matches on single 'b' character)