SublimeText/LaTeXTools — pull request #67 by Westacular (2012-08-29 18:36:36+00:00)
Title: Changed ref completions to also work with \ref{ and not require the "R*" mangling

I didn't like the way the autocomplete would temporarily replace the "ref_blah" with "R" -- I found it confusing, and it would leave the text in an unintended state with just an "R" there if you cancelled out of the autocomplete menu.

At the same time, I also thought that the autocomplete should work if you're inside an already-formatted \ref{} command.

The solution to the issues is related:

- If autocomplete is triggered with "ref_blah" preceding the cursor, first convert that to "\ref{blah" and then let the autocomplete system detect and handle the "blah" prefix/search on its own. The { acts as a word boundary, so you don't need to worry about "\ref{" polluting the search.

- If the autocomplete is triggered with "\ref{blah" preceding the cursor... detect that, don't change it, and just do the search.

I've tested this pretty thoroughly, I think, and it retains all the functionality of the former way it worked, while adding:

- the ability to cancel out of and later re-enter the reference autocomplete menu (i.e., no need to edit it back to "ref_"

- compatibility with things like the base LaTeX package's "figure" snippet, which generates "Figure~\ref{}" and places the cursor between the braces.