Evpok / latex-autocomplete

LaTeX autocompletion for atom
Other
9 stars 3 forks source link

Issue with multiple backslashes #11

Open Evpok opened 8 years ago

Evpok commented 8 years ago

The following

\\begin{enumerate}

is closed as if it was \begin{enumerate}. In other words, there is no distinction between a backslash beginning a macro and a backslash in a newline.

Evpok commented 8 years ago

TL;DR : give me a better regex engine and I'll fix it.

The current state of js regex engine doesn't allow lookbehinds, which is the only way I see of handling this without changing anything but the regex, using e.g. (?:(?<!\\)(?:\\\\)*)\\label{([^}]+)} to find actual instances of \label.

Another solution would be dirty manipulation of last match index, which I refuse to do. That would need too much refactoring, for no real benefit, as it seems unlikely anyone would actually mean to write \\label{...}.

larkvi commented 7 years ago

If you cannot tell whether there is a \ why not just have it autocomplete without the \?

I suppose it is a question of: if this cannot distinguish normal content typing and markup, why is it a better solution than not having it installed?

Evpok commented 7 years ago

If you cannot tell whether there is a \ why not just have it autocomplete without the \? Because the command we are completing is \begin, an not e.g. an hypothetical \atbegin. It also (probably) speeds up the search for \begins.

I suppose it is a question of: if this cannot distinguish normal content typing and markup, why is it a better solution than not having it installed? I fail to see your point

  • There is arguably no distinction between “content typing” and “markup” in LaTeX.
  • This issue is with an improbable line break followed by the literal word “begin” and something between braces, with no space between them. This is very unlikely to appear legitimately in a LaTeX document, so there is no real issue there.
  • The main point of this package is to close environments automatically, which it does reasonably well. That makes it a better solution to me than not having it installed. See what works for you.
  • This package provides autocompletion for a couple of other commands, however, mostly due to LaTeX nature, it is very hard to provide autocompletion for arbitrary commands, so the coverage is limited
  • I don't have much time to spare, so for the foreseeable future, this package will stay more or less in its current state, unless someone steps up and add support for more things.