mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-06 10:54:22 +08:00
show_goto_multi_results: use relpath
This helps Vim to display the path for unlisted buffers relative to cwd in the quickfix list.
This commit is contained in:
committed by
Dave Halter
parent
e7cb9a186e
commit
8e077adb2f
@@ -340,6 +340,14 @@ def goto(mode="goto"):
|
||||
return definitions
|
||||
|
||||
|
||||
def relpath(path):
|
||||
"""Make path relative to cwd if it is below."""
|
||||
abspath = os.path.abspath(path)
|
||||
if abspath.startswith(os.getcwd()):
|
||||
return os.path.relpath(path)
|
||||
return path
|
||||
|
||||
|
||||
def show_goto_multi_results(definitions):
|
||||
"""Create a quickfix list for multiple definitions."""
|
||||
lst = []
|
||||
@@ -352,7 +360,8 @@ def show_goto_multi_results(definitions):
|
||||
lst.append(dict(text=PythonToVimStr(d.description)))
|
||||
else:
|
||||
text = '[%s] %s' % (d.description, d.get_line_code().strip())
|
||||
lst.append(dict(filename=PythonToVimStr(d.module_path),
|
||||
filename = relpath(d.module_path)
|
||||
lst.append(dict(filename=PythonToVimStr(filename),
|
||||
lnum=d.line, col=d.column + 1,
|
||||
text=PythonToVimStr(text)))
|
||||
vim_eval('setqflist(%s)' % repr(lst))
|
||||
|
||||
Reference in New Issue
Block a user