mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-07 03:04:30 +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
|
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):
|
def show_goto_multi_results(definitions):
|
||||||
"""Create a quickfix list for multiple definitions."""
|
"""Create a quickfix list for multiple definitions."""
|
||||||
lst = []
|
lst = []
|
||||||
@@ -352,7 +360,8 @@ def show_goto_multi_results(definitions):
|
|||||||
lst.append(dict(text=PythonToVimStr(d.description)))
|
lst.append(dict(text=PythonToVimStr(d.description)))
|
||||||
else:
|
else:
|
||||||
text = '[%s] %s' % (d.description, d.get_line_code().strip())
|
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,
|
lnum=d.line, col=d.column + 1,
|
||||||
text=PythonToVimStr(text)))
|
text=PythonToVimStr(text)))
|
||||||
vim_eval('setqflist(%s)' % repr(lst))
|
vim_eval('setqflist(%s)' % repr(lst))
|
||||||
|
|||||||
Reference in New Issue
Block a user