-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for issue #1070 - Autocomplete for \cite{} and \ref{} looks in open buffers too #1071
base: master
Are you sure you want to change the base?
Fix for issue #1070 - Autocomplete for \cite{} and \ref{} looks in open buffers too #1071
Conversation
…buffers for .bib files before giving up when it can't find any linked .bib files
latex_cite_completions.py
Outdated
# find which buffers are .bib files | ||
result = [] | ||
for window in windows: | ||
result += [v.file_name() for v in window.views() if v.file_name().endswith(".bib")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to if v.file_name() is not None and v.file_name().endswith(".bib")
or just to if (v.file_name() or "").endswith(".bib")
to avoid an error, the view is not saved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
latex_ref_completions.py
Outdated
for view in views: | ||
# XXX: Hardcoded to only look for tex files, so that it doesn't try | ||
# looking for label commands in support files | ||
if view.file_name().endswith(".tex"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
I am not whether this is really an improvement, because the completions should depend on the tex document and not on the open files. However we may make it opt-in as a "hack" for people, who use a setup, which is currently not supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my two comments. I'm a bit unconvinced about this change overall, simply because it tends to assume that open views are necessarily related to the document at hand which may or may not be the case (for example, I often have papers related to the current paper I'm working on open while I'm working on another paper, but since the papers are separate TeX documents its somewhat inappropriate to draw references and labels from one into the other). I can see the value of this, however, if its added as a settings-configurable option that is opt-in by default.
for view in views: | ||
# XXX: Hardcoded to only look for tex files, so that it doesn't try | ||
# looking for label commands in support files | ||
if view.file_name() is None or view.file_name().endswith(".tex"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could probably be more sensibly implemented by checking the syntax (something like view.score_selector('text.tex.latex', 0) > 0
or at least checking for various extensions supported using the is_tex_file()
function in the latextools_utils.is_tex_file
module.
@@ -271,6 +271,22 @@ def _find_bib_files(): | |||
return cache.LocalCache(root).cache('bib_files', _find_bib_files) | |||
|
|||
|
|||
def find_open_bib_files(active_window_only=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer that the default option was to search the active window only since its possible to have multiple unrelated TeX documents open at the same time.
Fixes for #1070