mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
fix infinite cycle when template is descendant of an instance
This commit is contained in:
parent
96a5cb23f3
commit
0040334e89
@ -493,11 +493,20 @@ class NoteShort {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
hasAncestor(ancestorNote) {
|
hasAncestor(ancestorNote, visitedNoteIds) {
|
||||||
if (this.noteId === ancestorNote.noteId) {
|
if (this.noteId === ancestorNote.noteId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!visitedNoteIds) {
|
||||||
|
visitedNoteIds = new Set();
|
||||||
|
} else if (visitedNoteIds.has(this.noteId)) {
|
||||||
|
// to avoid infinite cycle when template is descendent of the instance
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
visitedNoteIds.add(this.noteId);
|
||||||
|
|
||||||
for (const templateNote of this.getTemplateNotes()) {
|
for (const templateNote of this.getTemplateNotes()) {
|
||||||
if (templateNote.hasAncestor(ancestorNote)) {
|
if (templateNote.hasAncestor(ancestorNote)) {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user