SublimeText / LaTeXTools

LaTeX plugin for Sublime Text
https://latextools.readthedocs.io/
2.01k stars 366 forks source link

Fill/Reference helper also reading commented out lines that have \label{} #704

Open excetara2 opened 8 years ago

excetara2 commented 8 years ago

The fill and reference helper ctrl+l, x is acting on all \label commands within the file even the commented out areas of the local file. Interestingly, this does not happen project wide but only in the commented out areas of the current file you are working on. If you switch to another file in the project the commented out areas are ignored from the other files in the project.

Also if no project is set the same happens within just a single file opened that any commented region the \label command is still read and input to the fill and reference helper.

Shouldn't the commented regions be ignored as default. Maybe a setting could change this if somebody desired?

r-stein commented 8 years ago

The current view is searched via ST build-in command. All included files are read, the comments are removed and afterwards searched. I agree the behavior is odd and could be changed.

In the long term the ref completion might switch to use the analysis, which solves this and other problem, e.g. labels behind \end{document] should be ignored and infinite recursion, if you have cyclic file includes (A includes B and B includes A).

excetara2 commented 8 years ago

@r-stein Okay I just wasn't sure if this was a bug in my system or the intended behavior to read commented lines. Yes the analysis looks like it could solve this problem and a great PR.

ig0774 commented 8 years ago

It's less useful for \labels, but occasionally some users have found having a line:

% \bibliography{...}

helpful to get some bib completions when LaTeXTools doesn't detect their bibliography, but that's something we should address through an actual feature.