diff --git a/src/nl/hannahsten/texifyidea/editor/folding/LatexMathSymbolFoldingBuilder.kt b/src/nl/hannahsten/texifyidea/editor/folding/LatexMathSymbolFoldingBuilder.kt index d5085f5d0..3ca27ca5f 100644 --- a/src/nl/hannahsten/texifyidea/editor/folding/LatexMathSymbolFoldingBuilder.kt +++ b/src/nl/hannahsten/texifyidea/editor/folding/LatexMathSymbolFoldingBuilder.kt @@ -9,8 +9,10 @@ import com.intellij.openapi.project.DumbAware import com.intellij.psi.PsiElement import nl.hannahsten.texifyidea.lang.commands.LatexMathCommand import nl.hannahsten.texifyidea.psi.LatexCommands +import nl.hannahsten.texifyidea.psi.LatexEnvironmentContent import nl.hannahsten.texifyidea.psi.LatexMathEnvironment import nl.hannahsten.texifyidea.util.parser.childrenOfType +import nl.hannahsten.texifyidea.util.parser.inMathContext /** * @author Sten Wessel @@ -19,9 +21,10 @@ class LatexMathSymbolFoldingBuilder : FoldingBuilderEx(), DumbAware { override fun buildFoldRegions(root: PsiElement, document: Document, quick: Boolean): Array { val descriptors = listOf().toMutableList() - val mathEnvironments = root.childrenOfType(LatexMathEnvironment::class) + val inlineOrDisplayMath = root.childrenOfType(LatexMathEnvironment::class) + val mathEnvironments = root.childrenOfType(LatexEnvironmentContent::class).filter { it.inMathContext() } - for (mathEnvironment in mathEnvironments) { + for (mathEnvironment in inlineOrDisplayMath + mathEnvironments) { val group = FoldingGroup.newGroup("latexMathSymbol") val commands = mathEnvironment.childrenOfType(LatexCommands::class) diff --git a/test/nl/hannahsten/texifyidea/editor/LatexFoldingTest.kt b/test/nl/hannahsten/texifyidea/editor/LatexFoldingTest.kt index 0cfbb8358..60a1c76f0 100644 --- a/test/nl/hannahsten/texifyidea/editor/LatexFoldingTest.kt +++ b/test/nl/hannahsten/texifyidea/editor/LatexFoldingTest.kt @@ -34,6 +34,13 @@ class LatexFoldingTest : BasePlatformTestCase() { } } + fun testMathSymbolFoldingInEnvironment() { + // Unicode issues on windows + if (!SystemInfo.isWindows) { + myFixture.testFolding("$testDataPath/math-symbols-environment.tex") + } + } + fun testSectionFolding() { myFixture.testFolding("$testDataPath/sections.tex") } diff --git a/test/resources/editor/folding/math-symbols-environment.tex b/test/resources/editor/folding/math-symbols-environment.tex new file mode 100644 index 000000000..32916bc05 --- /dev/null +++ b/test/resources/editor/folding/math-symbols-environment.tex @@ -0,0 +1,3 @@ +\begin{equation} + \xi^\alpha +\end{equation} \ No newline at end of file