diff --git a/src/nl/hannahsten/texifyidea/structure/latex/LatexStructureViewElement.kt b/src/nl/hannahsten/texifyidea/structure/latex/LatexStructureViewElement.kt index ae528ccdc..f60a5a4a8 100644 --- a/src/nl/hannahsten/texifyidea/structure/latex/LatexStructureViewElement.kt +++ b/src/nl/hannahsten/texifyidea/structure/latex/LatexStructureViewElement.kt @@ -195,7 +195,7 @@ class LatexStructureViewElement(private val element: PsiElement) : StructureView } // Avoid that an element is not added at all by adding it one level up anyway. // If index is null, that means that the tree currently only has elements with a higher order. - else { + else if (index == null || indexInsert == index) { registerSameLevel(sections, child, currentCmd, treeElements, numbering) break }