Skip to content

Build your personal knowledge base with Trilium Notes

fix autocomplete showing hidden paths, closes #3654

zadame2b8dfe96adb
diff --git a/src/services/search/expressions/note_flat_text.js b/src/services/search/expressions/note_flat_text.js
index 67aae1b836..863573a13b 100644
--- a/src/services/search/expressions/note_flat_text.js
+++ b/src/services/search/expressions/note_flat_text.js
@@ -28,15 +28,20 @@ class NoteFlatTextExp extends Expression {
if (retPath) {
const noteId = retPath[retPath.length - 1];
- executionContext.noteIdToNotePath[noteId] = retPath;
- resultNoteSet.add(becca.notes[noteId]);
+ if (!resultNoteSet.hasNoteId(noteId)) {
+ // we could get here from multiple paths, the first one wins because the paths
+ // are sorted by importance
+ executionContext.noteIdToNotePath[noteId] = retPath;
+
+ resultNoteSet.add(becca.notes[noteId]);
+ }
}
return;
}
- if (!note.parents.length === 0 || note.noteId === 'root') {
+ if (note.parents.length === 0 || note.noteId === 'root') {
return;
}
@@ -49,9 +54,11 @@ class NoteFlatTextExp extends Expression {
}
for (const attribute of note.ownedAttributes) {
+ const normalizedName = utils.normalize(attribute.name);
+ const normalizedValue = utils.normalize(attribute.value);
+
for (const token of tokens) {
- if (utils.normalize(attribute.name).includes(token)
- || utils.normalize(attribute.value).includes(token)) {
+ if (normalizedName.includes(token) || normalizedValue.includes(token)) {
foundAttrTokens.push(token);
}
}
@@ -70,10 +77,10 @@ class NoteFlatTextExp extends Expression {
if (foundTokens.length > 0) {
const remainingTokens = tokens.filter(token => !foundTokens.includes(token));
- searchDownThePath(parentNote, remainingTokens, path.concat([note.noteId]));
+ searchDownThePath(parentNote, remainingTokens, [...path, note.noteId]);
}
else {
- searchDownThePath(parentNote, tokens, path.concat([note.noteId]));
+ searchDownThePath(parentNote, tokens, [...path, note.noteId]);
}
}
}