forked from VimPlug/jedi-vim
Fix "goto" with multiple results
E.g. with `os.path`.
This commit is contained in:
@@ -434,6 +434,8 @@ def show_goto_multi_results(definitions, mode):
|
|||||||
"""Create (or reuse) a quickfix list for multiple definitions."""
|
"""Create (or reuse) a quickfix list for multiple definitions."""
|
||||||
global _current_definitions
|
global _current_definitions
|
||||||
|
|
||||||
|
for_usages = mode == "usages"
|
||||||
|
|
||||||
lst = []
|
lst = []
|
||||||
(row, col) = vim.current.window.cursor
|
(row, col) = vim.current.window.cursor
|
||||||
current_idx = None
|
current_idx = None
|
||||||
@@ -450,9 +452,10 @@ def show_goto_multi_results(definitions, mode):
|
|||||||
text=PythonToVimStr(text)))
|
text=PythonToVimStr(text)))
|
||||||
|
|
||||||
# Select current/nearest entry via :cc later.
|
# Select current/nearest entry via :cc later.
|
||||||
|
# Only done for "usages", but current_def is also used for "goto".
|
||||||
if d.line == row and d.column <= col:
|
if d.line == row and d.column <= col:
|
||||||
if (current_idx is None
|
if (current_idx is None
|
||||||
or (abs(lst[current_idx].column - col)
|
or (abs(lst[current_idx]["col"] - col)
|
||||||
> abs(d.column - col))):
|
> abs(d.column - col))):
|
||||||
current_idx = len(lst)
|
current_idx = len(lst)
|
||||||
current_def = d
|
current_def = d
|
||||||
@@ -472,9 +475,9 @@ def show_goto_multi_results(definitions, mode):
|
|||||||
VimCompat.setqflist_title(qf_title)
|
VimCompat.setqflist_title(qf_title)
|
||||||
else:
|
else:
|
||||||
VimCompat.setqflist(lst, title=qf_title, context=qf_context)
|
VimCompat.setqflist(lst, title=qf_title, context=qf_context)
|
||||||
for_usages = mode == "usages"
|
|
||||||
vim_eval('jedi#add_goto_window(%d, %d)' % (for_usages, len(lst)))
|
vim_eval('jedi#add_goto_window(%d, %d)' % (for_usages, len(lst)))
|
||||||
|
|
||||||
|
if for_usages:
|
||||||
vim_command('%dcc' % select_entry)
|
vim_command('%dcc' % select_entry)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user