diff --git a/src/nl/hannahsten/texifyidea/util/parser/LatexPsiUtil.kt b/src/nl/hannahsten/texifyidea/util/parser/LatexPsiUtil.kt index 83d9fc407..e32a16231 100644 --- a/src/nl/hannahsten/texifyidea/util/parser/LatexPsiUtil.kt +++ b/src/nl/hannahsten/texifyidea/util/parser/LatexPsiUtil.kt @@ -77,7 +77,7 @@ fun LatexEndCommand.beginCommand(): LatexBeginCommand? = previousSiblingOfType(L /** * Checks if the latex content objects is a display math environment. */ -fun LatexNoMathContent.isDisplayMath() = children.firstOrNull() is LatexMathEnvironment +fun LatexNoMathContent.isDisplayMath() = children.firstOrNull() is LatexMathEnvironment && children.first().firstChild is LatexDisplayMath /* * Technically it's impossible to determine for all cases whether a users wants to compile with biber or biblatex. diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/codestyle/LatexGatherEquationsInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/codestyle/LatexGatherEquationsInspectionTest.kt index 526ae77ea..6e8874c59 100644 --- a/test/nl/hannahsten/texifyidea/inspections/latex/codestyle/LatexGatherEquationsInspectionTest.kt +++ b/test/nl/hannahsten/texifyidea/inspections/latex/codestyle/LatexGatherEquationsInspectionTest.kt @@ -20,6 +20,33 @@ class LatexGatherEquationsInspectionTest : TexifyInspectionTestBase(LatexGatherE myFixture.checkHighlighting() } + fun `test two consecutive inline math environments`() { + myFixture.configureByText( + LatexFileType, + """ + ${"$"}a=b$ + ${"$"}b=a$ + """.trimIndent() + ) + myFixture.checkHighlighting() + } + + fun `test display math seperated by inline math environments`() { + myFixture.configureByText( + LatexFileType, + """ + \[ + a=b + \] + ${"$"}c=d$ + \[ + e=f + \] + """.trimIndent() + ) + myFixture.checkHighlighting() + } + fun `test two consecutive (non-display) math environments`() { myFixture.configureByText( LatexFileType,