change the heuristics to choose the best note path when ambiguous/incomplete/just noteId is provided, #1711

This commit is contained in:
zadam
2021-03-06 20:23:29 +01:00
parent 060d4fc27b
commit 9f002fa802
5 changed files with 60 additions and 43 deletions

View File

@@ -253,6 +253,32 @@ class NoteShort {
return noteAttributeCache.attributes[this.noteId];
}
getAllNotePaths() {
if (this.noteId === 'root') {
return [['root']];
}
const parentNotes = this.getParentNotes();
let paths;
if (parentNotes.length === 1) { // optimization for the most common case
paths = parentNotes[0].getAllNotePaths();
}
else {
paths = [];
for (const parentNote of parentNotes) {
paths.push(...parentNote.getAllNotePaths());
}
}
for (const path of paths) {
path.push(this.noteId);
}
return paths;
}
__filterAttrs(attributes, type, name) {
if (!type && !name) {
return attributes;