alexeyr / company-auctex

company-mode autocompletion for auctex
49 stars 18 forks source link

Completing an environment with a * results in an extra asterisk #2

Closed trishume closed 9 years ago

trishume commented 9 years ago

Completing an environment like align* by typing begali and moving down to the begalign* entry and hitting enter will result in:

  \begin{align*}

  \end{align*}*

Notice the extra asterisk after the end tag. This gets rendered and shouldn't be there. This happens with all environments that end with a *.

trishume commented 9 years ago

lol I figured it out, it's a pretty interesting bug. The problem is this code: https://github.com/alexeyr/company-auctex/blob/master/company-auctex.el#L204

It deletes the candidate with re-search-backwards without escaping the candidate. Since * is a regex special character it searches for things like alignnnn but doesn't match the asterisk itself.

Should be simple to fix: either use a non-regex search function or escape the candidate. I'm an elisp n00b but I'll try submitting a PR for this.