I accidentally submitted without adding the following important information: This bug only occurs when the environment is closed on the same line it is opened. It happens independent of which environment is opened, and the incorrect closing environment is always the actual last opened environment ignoring the current line.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I accidentally submitted without adding the following important information: This bug only occurs when the environment is closed on the same line it is opened. It happens independent of which environment is opened, and the incorrect closing environment is always the actual last opened environment ignoring the current line.
this is a design flaw which can't be fixed easily.
As you usually close environments only in later lines, I deem it acceptable.
hg 6257 (b34be4e5d400) implements a workaround that will handle this case correctly for most real-world examples.