diff --git a/jedi/api/completion.py b/jedi/api/completion.py index 0c2a8777..fa9ec325 100644 --- a/jedi/api/completion.py +++ b/jedi/api/completion.py @@ -1,4 +1,4 @@ -from parso import token +from parso.python import token from parso.python import tree from jedi import debug from jedi import settings diff --git a/jedi/api/helpers.py b/jedi/api/helpers.py index 3732d03c..53e920f0 100644 --- a/jedi/api/helpers.py +++ b/jedi/api/helpers.py @@ -3,10 +3,11 @@ Helpers for the API """ import re from collections import namedtuple +from textwrap import dedent from parso.python.parser import Parser from parso.python import tree -from parso.tokenize import tokenize +from parso.python.tokenize import tokenize from parso.utils import splitlines from jedi._compatibility import u @@ -127,7 +128,8 @@ def get_stack_at_position(grammar, code_lines, module_node, pos): else: yield token_ - code = _get_code_for_stack(code_lines, module_node, pos) + # The code might be indedented, just remove it. + code = dedent(_get_code_for_stack(code_lines, module_node, pos)) # We use a word to tell Jedi when we have reached the start of the # completion. # Use Z as a prefix because it's not part of a number suffix.