mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
Fix string completion issue, fixes #1528
This commit is contained in:
@@ -457,6 +457,8 @@ def _extract_string_while_in_string(leaf, position):
|
|||||||
if leaf.line == position[0]:
|
if leaf.line == position[0]:
|
||||||
kwargs['endpos'] = position[1] - leaf.column
|
kwargs['endpos'] = position[1] - leaf.column
|
||||||
match = _string_start.match(leaf.value, **kwargs)
|
match = _string_start.match(leaf.value, **kwargs)
|
||||||
|
if not match:
|
||||||
|
return None, None, None
|
||||||
start = match.group(0)
|
start = match.group(0)
|
||||||
if leaf.line == position[0] and position[1] < leaf.column + match.end():
|
if leaf.line == position[0] and position[1] < leaf.column + match.end():
|
||||||
return None, None, None
|
return None, None, None
|
||||||
|
|||||||
@@ -299,6 +299,9 @@ current_dirname = os.path.basename(dirname(dirname(dirname(__file__))))
|
|||||||
(f2, os_path + 'join(["tes"]', 10, ['t' + s]),
|
(f2, os_path + 'join(["tes"]', 10, ['t' + s]),
|
||||||
(f2, os_path + 'join(["tes"])', 10, ['t' + s]),
|
(f2, os_path + 'join(["tes"])', 10, ['t' + s]),
|
||||||
(f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),
|
(f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),
|
||||||
|
|
||||||
|
# GH #1528
|
||||||
|
(f2, "'a' 'b'", 4, Ellipsis),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_file_path_completions(Script, file, code, column, expected):
|
def test_file_path_completions(Script, file, code, column, expected):
|
||||||
@@ -306,7 +309,7 @@ def test_file_path_completions(Script, file, code, column, expected):
|
|||||||
if isinstance(column, tuple):
|
if isinstance(column, tuple):
|
||||||
line, column = column
|
line, column = column
|
||||||
comps = Script(code, path=file).complete(line=line, column=column)
|
comps = Script(code, path=file).complete(line=line, column=column)
|
||||||
if expected == "A LOT":
|
if expected is Ellipsis:
|
||||||
assert len(comps) > 100 # This is basically global completions.
|
assert len(comps) > 100 # This is basically global completions.
|
||||||
else:
|
else:
|
||||||
assert [c.complete for c in comps] == expected
|
assert [c.complete for c in comps] == expected
|
||||||
|
|||||||
Reference in New Issue
Block a user