mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Completions.complete returns None for fuzzy completions #1409
This commit is contained in:
@@ -408,11 +408,12 @@ class Completion(BaseDefinition):
|
||||
`Completion` objects are returned from :meth:`api.Script.completions`. They
|
||||
provide additional information about a completion.
|
||||
"""
|
||||
def __init__(self, inference_state, name, stack, like_name_length):
|
||||
def __init__(self, inference_state, name, stack, like_name_length, is_fuzzy):
|
||||
super(Completion, self).__init__(inference_state, name)
|
||||
|
||||
self._like_name_length = like_name_length
|
||||
self._stack = stack
|
||||
self._is_fuzzy = is_fuzzy
|
||||
|
||||
# Completion objects with the same Completion name (which means
|
||||
# duplicate items in the completion)
|
||||
@@ -438,6 +439,9 @@ class Completion(BaseDefinition):
|
||||
@property
|
||||
def complete(self):
|
||||
"""
|
||||
Only works with non-fuzzy completions. Returns None if fuzzy
|
||||
completions are used.
|
||||
|
||||
Return the rest of the word, e.g. completing ``isinstance``::
|
||||
|
||||
isinstan# <-- Cursor is here
|
||||
@@ -452,9 +456,9 @@ class Completion(BaseDefinition):
|
||||
|
||||
completing ``foo(par`` would give a ``Completion`` which `complete`
|
||||
would be `am=`
|
||||
|
||||
|
||||
"""
|
||||
if self._is_fuzzy:
|
||||
return None
|
||||
return self._complete(True)
|
||||
|
||||
@property
|
||||
|
||||
@@ -45,7 +45,8 @@ def filter_names(inference_state, completion_names, stack, like_name, fuzzy):
|
||||
inference_state,
|
||||
name,
|
||||
stack,
|
||||
len(like_name)
|
||||
len(like_name),
|
||||
is_fuzzy=fuzzy,
|
||||
)
|
||||
k = (new.name, new.complete) # key
|
||||
if k in comp_dct and settings.no_completion_duplicates:
|
||||
|
||||
@@ -62,7 +62,8 @@ def file_name_completions(inference_state, module_context, start_leaf, string,
|
||||
inference_state,
|
||||
FileName(inference_state, name[len(must_start_with) - like_name_length:]),
|
||||
stack=None,
|
||||
like_name_length=like_name_length
|
||||
like_name_length=like_name_length,
|
||||
is_fuzzy=fuzzy,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -331,7 +331,10 @@ def test_math_fuzzy_completion(Script, environment):
|
||||
expected = ['copysign', 'log', 'log10', 'log1p']
|
||||
if environment.version_info.major >= 3:
|
||||
expected.append('log2')
|
||||
assert expected == [comp.name for comp in script.completions(fuzzy=True)]
|
||||
completions = script.completions(fuzzy=True)
|
||||
assert expected == [comp.name for comp in completions]
|
||||
for c in completions:
|
||||
assert c.complete is None
|
||||
|
||||
|
||||
def test_file_fuzzy_completion(Script):
|
||||
|
||||
Reference in New Issue
Block a user