Goto bug fix.

This commit is contained in:
Dave Halter
2015-02-27 11:37:49 +01:00
parent 610068dde4
commit 1bc9ac1c00
2 changed files with 7 additions and 2 deletions

View File

@@ -407,7 +407,11 @@ class Script(object):
if last_name is None:
last_name = stmt
while not isinstance(last_name, pr.Name):
last_name = last_name.children[-1]
try:
last_name = last_name.children[-1]
except AttributeError:
# Doesn't have a name in it.
return []
if next(context) in ('class', 'def'):
# The cursor is on a class/function name.

View File

@@ -101,10 +101,11 @@ def test_completion_on_complex_literals():
assert api.Script('4j').completions() == []
def test_goto_assignments_on_non_statement():
def test_goto_assignments_on_non_name():
assert api.Script('for').goto_assignments() == []
assert api.Script('assert').goto_assignments() == []
assert api.Script('True').goto_assignments() == []
def test_goto_definition_not_multiple():