From 651eac91ff36f4a1c5826dc324ded7157271afaf Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 12 May 2015 19:38:31 +0200 Subject: [PATCH] goto: fix return value to always be a list Fixes https://github.com/davidhalter/jedi-vim/issues/414#issuecomment-101341260 --- jedi_vim.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jedi_vim.py b/jedi_vim.py index 7036967..331e661 100644 --- a/jedi_vim.py +++ b/jedi_vim.py @@ -199,9 +199,10 @@ def completions(): @catch_and_print_exceptions def goto(mode = "goto", no_output=False): """ - mode: "related_name", "definition", "assignment", "auto". + :param str mode: "related_name", "definition", "assignment", "auto" + :return: list of definitions/assignments + :rtype: list """ - definitions = [] script = get_script() try: if mode == "goto": @@ -217,6 +218,7 @@ def goto(mode = "goto", no_output=False): definitions = script.goto_assignments() except jedi.NotFoundError: echo_highlight("Cannot follow nothing. Put your cursor on a valid name.") + definitions = [] else: if no_output: return definitions @@ -239,7 +241,7 @@ def goto(mode = "goto", no_output=False): if d.module_path != vim.current.buffer.name: result = new_buffer(d.module_path) if not result: - return + return [] vim.current.window.cursor = d.line, d.column else: # multiple solutions