Handle the module_path better for namespaces

See also discussion in davidhalter/jedi#1033
This commit is contained in:
Dave Halter
2018-01-29 19:18:54 +01:00
parent 510b1c94e4
commit 79ced22a37

View File

@@ -294,8 +294,12 @@ def goto(mode="goto", no_output=False):
for d in definitions: for d in definitions:
if d.in_builtin_module(): if d.in_builtin_module():
lst.append(dict(text=PythonToVimStr('Builtin ' + d.description))) lst.append(dict(text=PythonToVimStr('Builtin ' + d.description)))
elif d.module_path is None:
# Typically a namespace, in the future maybe other things as
# well.
lst.append(dict(text=PythonToVimStr(d.description)))
else: else:
lst.append(dict(filename=PythonToVimStr(d.module_path), lst.append(dict(filename=PythonToVimStr(d.module_path or ''),
lnum=d.line, col=d.column + 1, lnum=d.line, col=d.column + 1,
text=PythonToVimStr(d.description))) text=PythonToVimStr(d.description)))
vim_eval('setqflist(%s)' % repr(lst)) vim_eval('setqflist(%s)' % repr(lst))
@@ -580,6 +584,7 @@ def do_rename(replace, orig=None):
continue continue
if os.path.abspath(vim.current.buffer.name) != r.module_path: if os.path.abspath(vim.current.buffer.name) != r.module_path:
assert r.module_path is not None
result = new_buffer(r.module_path) result = new_buffer(r.module_path)
if not result: if not result:
echo_highlight("Jedi-vim: failed to create buffer window for {0}!".format(r.module_path)) echo_highlight("Jedi-vim: failed to create buffer window for {0}!".format(r.module_path))