mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
add ignore_case to fuzzy matching
This commit is contained in:
parent
1e4ca4d67e
commit
c259978585
14
bin/autojump
14
bin/autojump
@ -254,11 +254,17 @@ def match_fuzzy(needles, haystack, ignore_case=False):
|
|||||||
|
|
||||||
This is a weak heuristic and be used as a last resort to find matches.
|
This is a weak heuristic and be used as a last resort to find matches.
|
||||||
"""
|
"""
|
||||||
needle = last(needles)
|
|
||||||
end_dir = lambda path: last(os.path.split(path))
|
end_dir = lambda path: last(os.path.split(path))
|
||||||
match_percent = lambda entry: SequenceMatcher(
|
if ignore_case:
|
||||||
a=needle,
|
needle = last(needles).lower()
|
||||||
b=end_dir(entry.path)).ratio()
|
match_percent = lambda entry: SequenceMatcher(
|
||||||
|
a=needle,
|
||||||
|
b=end_dir(entry.path.lower())).ratio()
|
||||||
|
else:
|
||||||
|
needle = last(needles)
|
||||||
|
match_percent = lambda entry: SequenceMatcher(
|
||||||
|
a=needle,
|
||||||
|
b=end_dir(entry.path)).ratio()
|
||||||
meets_threshold = lambda entry: match_percent(entry) \
|
meets_threshold = lambda entry: match_percent(entry) \
|
||||||
>= FUZZY_MATCH_THRESHOLD
|
>= FUZZY_MATCH_THRESHOLD
|
||||||
return ifilter(meets_threshold, haystack)
|
return ifilter(meets_threshold, haystack)
|
||||||
|
Loading…
Reference in New Issue
Block a user