Bug 274440

Summary: Kile: syntax highlighting failed to match aligned environment within equation
Product: [Applications] kile Reporter: outermeasure
Component: editorAssignee: Michel Ludwig <michel.ludwig>
Status: RESOLVED DUPLICATE    
Severity: normal CC: fmeier868, houstontyoung, nibgonz, raphael.kde
Priority: NOR    
Version First Reported In: 2.9.92   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: screenshot
Folding for cases/dcases
Folding for split
Updated LaTeX syntax highlighting file
Diff from original latex.xml to new one
Updated LaTeX syntax highlighting file (take two)
Diff from original latex.xml to new one (take two)

Description outermeasure 2011-05-29 18:25:59 UTC
Created attachment 60439 [details]
screenshot

Version:           2.1b5 (using KDE 4.6.2) 
OS:                Linux

Kile's syntax highlighting failed to match the \begin{aligned} with \end{aligned} if this block lie within an \begin{equation}...\end{equation}.  Also happens if it is within equation*, gather; and probably other amsmath defined environments too.

Doesn't happen within \[ ... \] or \( ... \).

Reproducible: Always

Steps to Reproduce:
minimum example:
\begin{equation}
\begin{aligned}
a & b\\
c & d
\end{aligned}
\end{equation}

Actual Results:  
The \end{aligned} isn't recognised --- the "\end{align" is usual colour (the default seems to be red for \end, black for {, and blue for align) but then "ed}" appears in green.  Also, folding the \begin{aligned} line folds up to and including the \end{equation}, and if you try to fold the \begin{equation} it will fold to at least the end of the next \begin{...}\end{...} (this seems to vary... haven't been able to determine a rule yet).

See screenshot attached for a slightly more complicated example.

Expected Results:  
The syntax highlighting should be aware that the \end{aligned} match the \begin{aligned}, etc.

OS: Linux (x86_64) release 2.6.37-hardened-r7
Compiler: x86_64-pc-linux-gnu-gcc
(Hardend amd64 Gentoo)
Comment 1 outermeasure 2011-06-02 14:30:38 UTC
The bug also show up in
\begin{equation}
\begin{cases}
(something)
\end{cases}
\end{equation}
and similar.
Comment 2 houstontyoung 2012-05-04 21:04:48 UTC
Same behavior for me; note the folding region on attached screenshots.

Kile 2.1.0
KDE 4.7.2
Ubuntu 11.04
Comment 3 houstontyoung 2012-05-04 21:07:21 UTC
Created attachment 70866 [details]
Folding for cases/dcases
Comment 4 houstontyoung 2012-05-04 21:07:43 UTC
Created attachment 70867 [details]
Folding for split
Comment 5 houstontyoung 2013-11-02 16:50:35 UTC
Here is a fix: I made some changes in the latex.xml file; the changed version is attached below, along with a diff from the original to the new one.

Just put the new latex.xml in ~/.kde/share/apps/katepart/syntax/ and restart kile.
Comment 6 houstontyoung 2013-11-02 16:58:24 UTC
Created attachment 83296 [details]
Updated LaTeX syntax highlighting file

Summary of changes:
- fixed "EndEnvironment" and replaced "MathFindEnd" with "EndMathEnv" contexts: this fixes the bug
- fixed "BeginEnvironment" context: removed pmatrix and friends from line pointing to "MathModeEnv"
- added highlighting for commands \Cref (from cleveref package) and \shortintertext (from mathtools package)
- added a new itemData "Reference" that is used for labels and citations; originally these share highlighting with "Environment"
Comment 7 houstontyoung 2013-11-02 16:59:32 UTC
Created attachment 83298 [details]
Diff from original latex.xml to new one
Comment 8 houstontyoung 2013-11-02 17:52:06 UTC
Created attachment 83299 [details]
Updated LaTeX syntax highlighting file (take two)
Comment 9 houstontyoung 2013-11-02 17:53:15 UTC
Created attachment 83300 [details]
Diff from original latex.xml to new one (take two)
Comment 10 merlin 2013-11-13 20:03:08 UTC
I have adapted the patch to current version 1.55 of latex.xml and sent it to the maintainer of Kile (Michel Ludwig) to commit it.
Comment 11 Andrew Crouthamel 2018-11-10 03:22:24 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 12 Andrew Crouthamel 2018-11-21 04:37:06 UTC
Dear Bug Submitter,

This is a reminder that this bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? This bug will be moved back to REPORTED Status for manual review later, which may take a while. If you are able to, please lend us a hand.

Thank you for helping us make KDE software even better for everyone!
Comment 13 houstontyoung 2018-11-22 20:40:11 UTC
I haven't used Kile in several years and don't use LaTeX much anymore.
Comment 14 Raphaël Jakse 2019-08-01 10:55:19 UTC
I just ran into this issue in the latest Kate with the following text:

\begin{align}
\begin{aligned}
\end{aligned}
\end{align}
Comment 15 Raphaël Jakse 2019-08-01 10:58:24 UTC
Still current in Kile version 2.9.92.
Comment 16 Nibaldo G. 2019-08-07 07:33:04 UTC

*** This bug has been marked as a duplicate of bug 410477 ***