mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
implement ignore_case for match_end()
This commit is contained in:
parent
c2189efb7b
commit
30d1b6d6f2
@ -205,8 +205,8 @@ def find_matches(config, needles, count=1):
|
|||||||
needles = map(sanitize, needles)
|
needles = map(sanitize, needles)
|
||||||
ignore_case = detect_smartcase(needles)
|
ignore_case = detect_smartcase(needles)
|
||||||
|
|
||||||
|
# if one needle, match only against the last directory of each path
|
||||||
if len(needles) == 1:
|
if len(needles) == 1:
|
||||||
# if one needle, match only against the last directory of each path
|
|
||||||
exact_matches = match_end(first(needles), data, ignore_case)
|
exact_matches = match_end(first(needles), data, ignore_case)
|
||||||
else:
|
else:
|
||||||
exact_matches = match_regex(needles, data, ignore_case)
|
exact_matches = match_regex(needles, data, ignore_case)
|
||||||
@ -219,7 +219,10 @@ def find_matches(config, needles, count=1):
|
|||||||
def match_end(needle, haystack, ignore_case=False):
|
def match_end(needle, haystack, ignore_case=False):
|
||||||
"""Matches needle against the last directory of path."""
|
"""Matches needle against the last directory of path."""
|
||||||
get_last_dir = lambda entry: second(os.path.split(entry.path))
|
get_last_dir = lambda entry: second(os.path.split(entry.path))
|
||||||
has_needle = lambda entry: needle in get_last_dir(entry)
|
if ignore_case:
|
||||||
|
has_needle = lambda entry: needle in get_last_dir(entry).lower()
|
||||||
|
else:
|
||||||
|
has_needle = lambda entry: needle in get_last_dir(entry)
|
||||||
return ifilter(has_needle, haystack)
|
return ifilter(has_needle, haystack)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user