From 08f13af066fad3a60cf241b37ac1878b8cfafa46 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 20 Oct 2019 23:56:22 +0200 Subject: [PATCH] completions: skip docstr without preview, handle exceptions (#958) Closes https://github.com/davidhalter/jedi-vim/issues/948. --- pythonx/jedi_vim.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pythonx/jedi_vim.py b/pythonx/jedi_vim.py index 648549e..513b79f 100644 --- a/pythonx/jedi_vim.py +++ b/pythonx/jedi_vim.py @@ -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())) out.append(d) strout = str(out)