Fix .Parent when there are overlapping regular pages inbetween

Fixes #12263
This commit is contained in:
Bjørn Erik Pedersen
2024-03-15 18:07:28 +01:00
parent 558f74f009
commit f1d755965f
2 changed files with 32 additions and 4 deletions

View File

@@ -124,11 +124,16 @@ func (pt pageTree) Parent() page.Page {
return pt.p.s.home
}
_, n := pt.p.s.pageMap.treePages.LongestPrefix(dir, true, nil)
if n != nil {
return n.(page.Page)
for {
_, n := pt.p.s.pageMap.treePages.LongestPrefix(dir, true, nil)
if n == nil {
return pt.p.s.home
}
if pt.p.m.bundled || n.isContentNodeBranch() {
return n.(page.Page)
}
dir = paths.Dir(dir)
}
return nil
}
func (pt pageTree) Ancestors() page.Pages {