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

completions: skip docstr without preview, handle exceptions #958

Merged
merged 1 commit into from Oct 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion pythonx/jedi_vim.py
Expand Up @@ -305,16 +305,22 @@ def completions():
completions = script.completions()
signatures = script.call_signatures()

add_info = "preview" in vim.eval("&completeopt").split(",")
out = []
for c in completions:
d = dict(word=PythonToVimStr(c.name[:len(base)] + c.complete),
abbr=PythonToVimStr(c.name_with_symbols),
# stuff directly behind the completion
menu=PythonToVimStr(c.description),
info=PythonToVimStr(c.docstring()), # docstr
icase=1, # case insensitive
dup=1 # allow duplicates (maybe later remove this)
)
if add_info:
try:
d["info"] = PythonToVimStr(c.docstring())
except Exception:
print("jedi-vim: error with docstring for %r: %s" % (
c, traceback.format_exc()))
Copy link
Owner

Choose a reason for hiding this comment

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

Just wondering: Do we need that? Or is this already covered by the generic error handling and you just want to know a bit more about the error (essentially the added c information)?

Otherwise I think this is a good change. Not sure though how many people aren't using preview. How about you?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not using preview, but it is enabled by default IIRC.
I've thought it is good to log/print errors (otherwise we might have never noticed that it fails with parts of numpy in the first place likely). It will only show up with :mess though.
The decorator would only print it when not swallowed (what is done here now).

out.append(d)

strout = str(out)
Expand Down