small refactorings

This commit is contained in:
zadam 2020-08-30 23:19:55 +02:00
parent b793f8cb88
commit 5fd58def11
2 changed files with 4 additions and 7 deletions

View file

@ -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);
}
}

View file

@ -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 <b> and </b> tag (to avoid matches on single 'b' character)