mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
Goto definition doesn't work on strings anymore, fixes microsoft/vscode#81520
This commit is contained in:
@@ -238,7 +238,7 @@ class Script(object):
|
|||||||
leaf = self._module_node.get_name_of_position(self._pos)
|
leaf = self._module_node.get_name_of_position(self._pos)
|
||||||
if leaf is None:
|
if leaf is None:
|
||||||
leaf = self._module_node.get_leaf_for_position(self._pos)
|
leaf = self._module_node.get_leaf_for_position(self._pos)
|
||||||
if leaf is None:
|
if leaf is None or leaf.type == 'string':
|
||||||
return []
|
return []
|
||||||
|
|
||||||
context = self._get_module_context().create_context(leaf)
|
context = self._get_module_context().create_context(leaf)
|
||||||
|
|||||||
@@ -342,3 +342,19 @@ def test_file_fuzzy_completion(Script):
|
|||||||
script = Script('"{}/ep08_i'.format(path))
|
script = Script('"{}/ep08_i'.format(path))
|
||||||
assert ['pep0484_basic.py"', 'pep0484_typing.py"'] \
|
assert ['pep0484_basic.py"', 'pep0484_typing.py"'] \
|
||||||
== [comp.name for comp in script.completions(fuzzy=True)]
|
== [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()
|
||||||
|
|||||||
Reference in New Issue
Block a user