Skip to content

Commit

Permalink
Merge pull request #3386 from jojo2357/gathering
Browse files Browse the repository at this point in the history
Fix equation gathering
  • Loading branch information
PHPirates authored Jan 11, 2024
2 parents 7bb87e8 + dd05dc3 commit 5ee64bc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/nl/hannahsten/texifyidea/util/parser/LatexPsiUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fun LatexEndCommand.beginCommand(): LatexBeginCommand? = previousSiblingOfType(L
/**
* Checks if the latex content objects is a display math environment.
*/
fun LatexNoMathContent.isDisplayMath() = firstChildOfType(LatexDisplayMath::class) != null && firstChildOfType(LatexEnvironment::class) == null
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -35,6 +62,19 @@ class LatexGatherEquationsInspectionTest : TexifyInspectionTestBase(LatexGatherE
myFixture.checkHighlighting()
}

fun `test two consecutive (non-display) math environments in item`() {
myFixture.configureByText(
LatexFileType,
"""
\begin{enumerate}
\item{\[a=b\]}
\item{\[b=a\]}
\end{enumerate}
""".trimIndent()
)
myFixture.checkHighlighting()
}

fun `test quick fix`() {
testQuickFix(
"""
Expand Down

0 comments on commit 5ee64bc

Please sign in to comment.