latexer icon indicating copy to clipboard operation
latexer copied to clipboard

Creating too many ends of environments (when activating autocomplete environments)

Open kellertuer opened this issue 8 years ago • 5 comments

Hi there, I would like to use the latexer for easier typing of TeX. However there seems to be a bug with Atom 1.18.0 and latexer 0.3.0.

When I begin an unnumbered math equation environment \[ and type enter I would expect and autocompletion like

\[

\]

But I get the following

\[

\]
\]
\]
\]
\]
\]
\]
\]
\]

which is quite annoying, since it also happens, when you have the scenario from the first block code (so an existing empty or even nonempty math environment) and place the cursor at the equation line within at the second character (where you would end up after pressing enter).

edit: The error dissappears when disabling autocomplete environments but of course then environments are not autocompleted ;)

kellertuer avatar Jul 19 '17 07:07 kellertuer

Hmm, yes that is quite annoying. Unfortunately I can't seem to replicate it. Could you possibly try the github version? Or wait until end of week for 0.3.1 and try it with that?

Focus avatar Sep 21 '17 10:09 Focus

I can confirm the bug. I have a feeling that the occurrence of too many ]-s is more likely within another environment. For example I had this trouble when I needed to write display formulae within a block environment in beamer.

janwil123 avatar Sep 30 '17 10:09 janwil123

Could you possibly provide a small reproducible example?

Focus avatar Oct 03 '17 21:10 Focus

Sure. I stripped my file down to the following one-slide example:

beamertest.txt

(sorry I had to rename it to .txt since GitHub does not like uploading .tex files).

To reproduce the error do the following:

  • Open the file in Atom (with latexer enabled) as a .tex-file.
  • Find the display math formula in the itemize environment, place your cursor in the end of the formula and hit spacebar.
  • You will see erroneous [ and ] added in weird places.

What seems to be interesting is that when I delete the preceding block environment, the bug disappears. So probably its logic of traversing the environments after and through each other leaves the state machine in an incorrect state.

And you get extra 5 point credit for figuring out what language the example slide is written in :)

Best, Jan

janwil123 avatar Oct 04 '17 05:10 janwil123

Thanks for providing the example, I even forgot about the bug for a while (since I switched back to my old editor). Yes, that replicates the bug and occurs often in beamer slides. It also happens therein with the equation environment, but in a slightly different setting, i'll try to also boil that down to a minimal example and report back.

kellertuer avatar Nov 05 '17 09:11 kellertuer