fix autocomplete showing hidden paths, closes #3654

This commit is contained in:
zadam 2023-02-28 23:23:48 +01:00
parent f883fde74a
commit e2b8dfe96a

View File

@ -28,15 +28,20 @@ class NoteFlatTextExp extends Expression {
if (retPath) { if (retPath) {
const noteId = retPath[retPath.length - 1]; 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; return;
} }
if (!note.parents.length === 0 || note.noteId === 'root') { if (note.parents.length === 0 || note.noteId === 'root') {
return; return;
} }
@ -49,9 +54,11 @@ class NoteFlatTextExp extends Expression {
} }
for (const attribute of note.ownedAttributes) { for (const attribute of note.ownedAttributes) {
const normalizedName = utils.normalize(attribute.name);
const normalizedValue = utils.normalize(attribute.value);
for (const token of tokens) { for (const token of tokens) {
if (utils.normalize(attribute.name).includes(token) if (normalizedName.includes(token) || normalizedValue.includes(token)) {
|| utils.normalize(attribute.value).includes(token)) {
foundAttrTokens.push(token); foundAttrTokens.push(token);
} }
} }
@ -70,10 +77,10 @@ class NoteFlatTextExp extends Expression {
if (foundTokens.length > 0) { if (foundTokens.length > 0) {
const remainingTokens = tokens.filter(token => !foundTokens.includes(token)); const remainingTokens = tokens.filter(token => !foundTokens.includes(token));
searchDownThePath(parentNote, remainingTokens, path.concat([note.noteId])); searchDownThePath(parentNote, remainingTokens, [...path, note.noteId]);
} }
else { else {
searchDownThePath(parentNote, tokens, path.concat([note.noteId])); searchDownThePath(parentNote, tokens, [...path, note.noteId]);
} }
} }
} }