mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Fix an issue around completions in comments before strings
This commit is contained in:
@@ -283,6 +283,9 @@ class Completion:
|
|||||||
|
|
||||||
|
|
||||||
def _extract_string_while_in_string(leaf, position):
|
def _extract_string_while_in_string(leaf, position):
|
||||||
|
if position < leaf.start_pos:
|
||||||
|
return None, None
|
||||||
|
|
||||||
if leaf.type == 'string':
|
if leaf.type == 'string':
|
||||||
match = re.match(r'^\w*(\'{3}|"{3}|\'|")', leaf.value)
|
match = re.match(r'^\w*(\'{3}|"{3}|\'|")', leaf.value)
|
||||||
quote = match.group(1)
|
quote = match.group(1)
|
||||||
|
|||||||
@@ -125,6 +125,10 @@ def test_in_comment(Script):
|
|||||||
assert not Script("max_attr_value = int(2) # Cast to int for spe").completions()
|
assert not Script("max_attr_value = int(2) # Cast to int for spe").completions()
|
||||||
|
|
||||||
|
|
||||||
|
def test_in_comment_before_string(Script):
|
||||||
|
assert not Script(" # Foo\n'asdf'", line=1).completions()
|
||||||
|
|
||||||
|
|
||||||
def test_async(Script, environment):
|
def test_async(Script, environment):
|
||||||
if environment.version_info < (3, 5):
|
if environment.version_info < (3, 5):
|
||||||
pytest.skip()
|
pytest.skip()
|
||||||
|
|||||||
Reference in New Issue
Block a user