mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-10 15:51:51 +08:00
fix a completion in dict problem
This commit is contained in:
@@ -68,13 +68,19 @@ def check_arr_index(arr, pos):
|
|||||||
def array_for_pos(stmt, pos, array_types=None):
|
def array_for_pos(stmt, pos, array_types=None):
|
||||||
"""Searches for the array and position of a tuple"""
|
"""Searches for the array and position of a tuple"""
|
||||||
def search_array(arr, pos):
|
def search_array(arr, pos):
|
||||||
for i, stmt in enumerate(arr):
|
if arr.type == 'dict':
|
||||||
new_arr, index = array_for_pos(stmt, pos, array_types)
|
for stmt in arr.values + arr.keys:
|
||||||
if new_arr is not None:
|
new_arr, index = array_for_pos(stmt, pos, array_types)
|
||||||
return new_arr, index
|
if new_arr is not None:
|
||||||
if arr.start_pos < pos <= stmt.end_pos:
|
return new_arr, index
|
||||||
if not array_types or arr.type in array_types:
|
else:
|
||||||
return arr, i
|
for i, stmt in enumerate(arr):
|
||||||
|
new_arr, index = array_for_pos(stmt, pos, array_types)
|
||||||
|
if new_arr is not None:
|
||||||
|
return new_arr, index
|
||||||
|
if arr.start_pos < pos <= stmt.end_pos:
|
||||||
|
if not array_types or arr.type in array_types:
|
||||||
|
return arr, i
|
||||||
if len(arr) == 0 and arr.start_pos < pos < arr.end_pos:
|
if len(arr) == 0 and arr.start_pos < pos < arr.end_pos:
|
||||||
if not array_types or arr.type in array_types:
|
if not array_types or arr.type in array_types:
|
||||||
return arr, 0
|
return arr, 0
|
||||||
|
|||||||
@@ -181,6 +181,11 @@ def f():
|
|||||||
|
|
||||||
#? dict()
|
#? dict()
|
||||||
f()
|
f()
|
||||||
|
|
||||||
|
# completion within dicts
|
||||||
|
#? 9 ['str']
|
||||||
|
{str: str}
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# with variable as index
|
# with variable as index
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user