From dd05dc300f3820a2af3a6a587b6e9bbcb6380ae7 Mon Sep 17 00:00:00 2001 From: jojo2357 <66704796+jojo2357@users.noreply.github.com> Date: Wed, 10 Jan 2024 00:25:31 -0700 Subject: [PATCH] Distinguish inline from display --- .../texifyidea/util/parser/LatexPsiUtil.kt | 2 +- .../LatexGatherEquationsInspectionTest.kt | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) 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,