Hannah-Sten / TeXiFy-IDEA

LaTeX support for the IntelliJ platform by JetBrains.
https://hannah-sten.github.io/TeXiFy-IDEA
MIT License
874 stars 86 forks source link

\begin and \end in \newcommand: math highlighting and folding #3546

Open jojo2357 opened 2 months ago

jojo2357 commented 2 months ago

Not sure if it is intentional, but given a command definition we do not have folding of environments or syntax highlighting.

\newcommand{\balign}[0]{
    \begin{align}
        Miss aligned
    \end{align}
}

I understand that you do not need to close every environ that you open, but if we detect a complete environ, I dont see why we cant treat it as such?

If the amount of false-positive errors would be too large, then I'll close this and be sad. Maybe a magic comment is in order?

image

PHPirates commented 2 months ago

This is indeed on purpose, see #3101 . Unfortunately we have to decide at lexer level whether they are \begin and \end commands or not, if they are then the parser will break if they are unmatched. What we could maybe still do, is make them a special 'weak \begin' token type and 'optionally' match them just like [...] brackets , I'm not sure though if we can then get the math highlighting and folding back.