shortcuts improvements

This commit is contained in:
zadam
2022-11-26 14:57:39 +01:00
parent 6883b71ce7
commit 6a9ac6f90a
9 changed files with 97 additions and 23 deletions

View File

@@ -83,8 +83,10 @@ function getNoteTitleArrayForPath(notePathArray) {
throw new Error(`${notePathArray} is not an array.`);
}
if (notePathArray.length === 1 && notePathArray[0] === cls.getHoistedNoteId()) {
return [getNoteTitle(cls.getHoistedNoteId())];
const hoistedNoteId = cls.getHoistedNoteId();
if (notePathArray.length === 1 && notePathArray[0] === hoistedNoteId) {
return [getNoteTitle(hoistedNoteId)];
}
const titles = [];
@@ -92,6 +94,9 @@ function getNoteTitleArrayForPath(notePathArray) {
let parentNoteId = 'root';
let hoistedNotePassed = false;
// this is a notePath from outside of hoisted subtree so full title path needs to be returned
const outsideOfHoistedSubtree = !notePathArray.includes(hoistedNoteId);
for (const noteId of notePathArray) {
// start collecting path segment titles only after hoisted note
if (hoistedNotePassed) {
@@ -100,7 +105,7 @@ function getNoteTitleArrayForPath(notePathArray) {
titles.push(title);
}
if (noteId === cls.getHoistedNoteId()) {
if (!hoistedNotePassed && (noteId === hoistedNoteId || outsideOfHoistedSubtree)) {
hoistedNotePassed = true;
}