mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-22 21:31:26 +08:00
Added match_method parameter
This commit is contained in:
@@ -44,7 +44,7 @@ def fuzzy_match(string, like_name):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def filter_names(inference_state, completion_names, stack, like_name):
|
def filter_names(inference_state, completion_names, stack, like_name, match_method):
|
||||||
comp_dct = {}
|
comp_dct = {}
|
||||||
if settings.case_insensitive_completion:
|
if settings.case_insensitive_completion:
|
||||||
like_name = like_name.lower()
|
like_name = like_name.lower()
|
||||||
@@ -53,7 +53,7 @@ def filter_names(inference_state, completion_names, stack, like_name):
|
|||||||
if settings.case_insensitive_completion:
|
if settings.case_insensitive_completion:
|
||||||
string = string.lower()
|
string = string.lower()
|
||||||
|
|
||||||
if fuzzy_match(string, like_name):
|
if match_method(string, like_name):
|
||||||
new = classes.Completion(
|
new = classes.Completion(
|
||||||
inference_state,
|
inference_state,
|
||||||
name,
|
name,
|
||||||
@@ -100,7 +100,10 @@ class Completion:
|
|||||||
self._position = position[0], position[1] - len(self._like_name)
|
self._position = position[0], position[1] - len(self._like_name)
|
||||||
self._call_signatures_callback = call_signatures_callback
|
self._call_signatures_callback = call_signatures_callback
|
||||||
|
|
||||||
def completions(self):
|
def completions(self, **kwargs):
|
||||||
|
return self._completions(**kwargs)
|
||||||
|
|
||||||
|
def _completions(self, method=start_match):
|
||||||
leaf = self._module_node.get_leaf_for_position(self._position, include_prefixes=True)
|
leaf = self._module_node.get_leaf_for_position(self._position, include_prefixes=True)
|
||||||
string, start_leaf = _extract_string_while_in_string(leaf, self._position)
|
string, start_leaf = _extract_string_while_in_string(leaf, self._position)
|
||||||
if string is not None:
|
if string is not None:
|
||||||
@@ -115,7 +118,7 @@ class Completion:
|
|||||||
completion_names = self._get_value_completions(leaf)
|
completion_names = self._get_value_completions(leaf)
|
||||||
|
|
||||||
completions = filter_names(self._inference_state, completion_names,
|
completions = filter_names(self._inference_state, completion_names,
|
||||||
self.stack, self._like_name)
|
self.stack, self._like_name, method)
|
||||||
|
|
||||||
return sorted(completions, key=lambda x: (x.name.startswith('__'),
|
return sorted(completions, key=lambda x: (x.name.startswith('__'),
|
||||||
x.name.startswith('_'),
|
x.name.startswith('_'),
|
||||||
|
|||||||
Reference in New Issue
Block a user