Goto definition doesn't work on strings anymore, fixes microsoft/vscode#81520

This commit is contained in:
Dave Halter
2019-12-20 10:29:54 +01:00
parent 540a57766d
commit 45edfbdeeb
2 changed files with 17 additions and 1 deletions

View File

@@ -238,7 +238,7 @@ class Script(object):
leaf = self._module_node.get_name_of_position(self._pos)
if leaf is None:
leaf = self._module_node.get_leaf_for_position(self._pos)
if leaf is None:
if leaf is None or leaf.type == 'string':
return []
context = self._get_module_context().create_context(leaf)

View File

@@ -342,3 +342,19 @@ def test_file_fuzzy_completion(Script):
script = Script('"{}/ep08_i'.format(path))
assert ['pep0484_basic.py"', 'pep0484_typing.py"'] \
== [comp.name for comp in script.completions(fuzzy=True)]
@pytest.mark.parametrize(
'code, column', [
('"foo"', 0),
('"foo"', 3),
('"foo"', None),
('"""foo"""', 5),
('"""foo"""', 1),
('"""foo"""', 2),
]
)
def test_goto_on_string(Script, code, column):
script = Script(code, column=column)
assert not script.goto_definitions()
assert not script.goto_assignments()