Repository: hannah-sten/texify-idea
Issue: "Escape character \\ expected" when using underscore in array

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
IntelliJ Ultimate 2022.2.1 (`#IU-222.3739.54`)

#### Operating System 
Linux, Debian 12 (testing)

#### TeXiFy IDEA version
0.7.21

#### What I did (steps to reproduce)
I used an underscore in the `array` environment. I want to use the underscore to create a subscript.

#### Minimal example to reproduce the problem
```latex
\\begin{document}
    \\begin{equation}
        \\begin{array}{cc}
            \\theta_1 & \\theta_2 \\\\
            \\theta_3 & \\theta_4
        \\end{array}
        \\label{eq:my-equation}
    \\end{equation}
\\end{document}
```

#### Expected behavior
All inspections pass, because it's fine to use an underscore in a cell in the `array` environment.

#### Actual behavior
At all four underscores in the `array` environment, the following inspection is triggered: `Escape character \\ expected`.


Changed files:
test/nl/hannahsten/texifyidea/inspections/latex/probablebugs/LatexEscapeUnderscoreInspectionTest.kt
src/nl/hannahsten/texifyidea/lang/LatexMathEnvironment.kt
src/nl/hannahsten/texifyidea/lang/DefaultEnvironment.kt

diff --git a/src/nl/hannahsten/texifyidea/lang/DefaultEnvironment.kt b/src/nl/hannahsten/texifyidea/lang/DefaultEnvironment.kt
index 17a738b38..1f3ae65b5 100644
--- a/src/nl/hannahsten/texifyidea/lang/DefaultEnvironment.kt
+++ b/src/nl/hannahsten/texifyidea/lang/DefaultEnvironment.kt
@@ -27,7 +27,7 @@ enum class DefaultEnvironment(
     // Vanilla LaTeX
     ABSTRACT(environmentName = "abstract"),
     ALLTT(environmentName = "alltt"),
-    ARRAY(environmentName = "array", arguments = arrayOf(RequiredArgument("cols"))),
+    ARRAY(environmentName = "array", arguments = arrayOf(RequiredArgument("cols")), context = Context.MATH),
     CENTER(environmentName = "center"),
     DESCRIPTION(environmentName = "description", initialContents = "\\\\item "),
     DISPLAYMATH(environmentName = "displaymath", context = Context.MATH),
diff --git a/src/nl/hannahsten/texifyidea/lang/LatexMathEnvironment.kt b/src/nl/hannahsten/texifyidea/lang/LatexMathEnvironment.kt
deleted file mode 100644
index 9c01000e1..000000000
--- a/src/nl/hannahsten/texifyidea/lang/LatexMathEnvironment.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-package nl.hannahsten.texifyidea.lang
-
-import nl.hannahsten.texifyidea.lang.commands.Argument
-import nl.hannahsten.texifyidea.lang.commands.OptionalArgument
-import nl.hannahsten.texifyidea.lang.commands.RequiredArgument
-import java.util.*
-
-/**
- * @author Sten Wessel
- */
-enum class LatexMathEnvironment(
-    val environmentName: String,
-    vararg val arguments: Argument,
-    val initialContents: String? = null
-) {
-
-    /*
-     *  Default LaTeX.
-     */
-    ARRAY("array", OptionalArgument("pos"), RequiredArgument("cols")),
-    BMATRIX("bmatrix"),
-    CAPITAL_BMATRIX("Bmatrix"),
-    MATRIX("matrix"),
-    PMATRIX("pmatrix"),
-    VMATRIX("vmatrix"),
-    CAPITAL_VMATRIX("Vmatrix");
-
-    companion object {
-
-        private val lookup = HashMap<String, LatexMathEnvironment>()
-
-        init {
-            for (environment in values()) {
-                lookup[environment.environmentName] = environment
-            }
-        }
-
-        @JvmStatic
-        operator fun get(name: String) = lookup[name]
-    }
-}
\\ No newline at end of file
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/probablebugs/LatexEscapeUnderscoreInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/probablebugs/LatexEscapeUnderscoreInspectionTest.kt
index d3f0bf1da..416c4f7de 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/probablebugs/LatexEscapeUnderscoreInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/probablebugs/LatexEscapeUnderscoreInspectionTest.kt
@@ -140,6 +140,22 @@ internal class LatexEscapeUnderscoreInspectionTest : TexifyInspectionTestBase(La
         myFixture.checkHighlighting(true, false, false, false)
     }
 
+    fun `test unescaped _ character triggers no warning in math`() {
+        myFixture.configureByText(
+            LatexFileType,
+            """
+                \\begin{equation}
+                    \\begin{array}{cc}
+                        \\theta_1 & \\theta_2 \\\\
+                        \\theta_3 & \\theta_4
+                    \\end{array}
+                    \\label{eq:my-equation}
+                \\end{equation}
+            """.trimIndent()
+        )
+        myFixture.checkHighlighting(true, false, false, false)
+    }
+
     fun `test unescaped _ character quick fix`() {
         testQuickFix(
             """