Skip to content

Commit

Permalink
Support section levels
Browse files Browse the repository at this point in the history
  • Loading branch information
PHPirates committed Dec 19, 2024
1 parent cd88255 commit fd9a091
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ open class LatexBreadcrumbsInfo : BreadcrumbsProvider {
val parent = LatexSectionFoldingBuilder().buildFoldRegions(element.containingFile, document, quick = true)
// Only top-level elements in the section should have the section as parents, other elements should keep their direct parent (e.g. an environment)
.filter { it.range.contains(element.textRange ?: return@filter false) }
.filterNot { it.range.contains(element.parent.textRange ?: return@filterNot true) }
.firstOrNull { it.element.psi != element }
.filter { !it.range.contains(element.parent.textRange ?: return@filter false) }
// Avoid creating a loop
.filter { it.element.psi != element }
.filter { it.element.psi?.parents()?.contains(element) != true }
.minByOrNull { it.range.endOffset - it.range.startOffset }
?.element?.psi
// Avoid creating a loop
if (parent?.parents()?.contains(element) == true) { return super.getParent(element) }
return parent ?: super.getParent(element)
}
}

0 comments on commit fd9a091

Please sign in to comment.