Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Aligorith
Copy link

Fixes for #1070

…buffers for .bib files before giving up when it can't find any linked .bib files
# 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")]
Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

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"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

@r-stein
Copy link
Member

r-stein commented Apr 4, 2017

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.

Copy link
Contributor

@ig0774 ig0774 left a 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"):
Copy link
Contributor

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):
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants