diff --git a/jedi/api.py b/jedi/api.py index 07aa6e3d..3b49b40e 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -177,7 +177,7 @@ class Script(object): def _prepare_goto(self, goto_path, is_like_search=False): """ Base for complete, goto and get_definition. Basically it returns the resolved scopes under cursor. """ - debug.dbg('start: %s in %s' % (goto_path, self.parser.scope)) + debug.dbg('start: %s in %s' % (goto_path, self.parser.user_scope)) user_stmt = self.parser.user_stmt debug.speed('parsed') diff --git a/jedi/common.py b/jedi/common.py index 4d72f0d0..7eadf08a 100644 --- a/jedi/common.py +++ b/jedi/common.py @@ -61,6 +61,7 @@ class NoErrorTokenizer(object): self.gen = PushBackIterator(tokenize.generate_tokens(readline)) self.line_offset = line_offset self.stop_on_scope = stop_on_scope + self.first_scope = False def push_last_back(self): self.gen.push_back(self.current) @@ -94,9 +95,13 @@ class NoErrorTokenizer(object): # stop if a new class or definition is started at position zero. if self.stop_on_scope and c[1] in ['def', 'class'] and c[2][1] == 0: - raise StopIteration() + if self.first_scope: + raise StopIteration() + else: + self.first_scope = True c[2] = self.line_offset + c[2][0], c[2][1] + c[3] = self.line_offset + c[3][0], c[3][1] return c diff --git a/jedi/helpers.py b/jedi/helpers.py index 1d46b150..877e2300 100644 --- a/jedi/helpers.py +++ b/jedi/helpers.py @@ -252,5 +252,3 @@ def scan_array_for_pos(arr, pos): # The third return is just necessary for recursion inside, because # it needs to know when to stop iterating. return call, check_arr_index(), stop - -