1
0
mirror of https://github.com/wting/autojump synced 2026-03-02 03:49:26 +00:00

implement smartcase detection

This commit is contained in:
William Ting
2013-12-17 10:35:43 -06:00
parent bb04405cd6
commit d9b205c935
2 changed files with 13 additions and 1 deletions

View File

@@ -40,6 +40,7 @@ from data import save
from utils import decode
from utils import encode_local
from utils import first
from utils import has_uppercase
from utils import is_osx
from utils import print_entry
@@ -200,10 +201,11 @@ def find_matches(config, needles, count=1):
if not needles:
return first(data).path
ignore_case = detect_smartcase(needles)
sanitize = lambda x: decode(x).rstrip(os.sep)
needles = imap(sanitize, needles)
exact_matches = match_exact_regex(needles, data)
exact_matches = match_exact_regex(needles, data, ignore_case)
return first(exact_matches).path
@@ -255,6 +257,11 @@ def print_stats(config):
print("\ndata:\t %s" % config['data_path'])
def detect_smartcase(strings):
"""Detect if any uppercase letters are present in any of the strings."""
return not any(imap(has_uppercase, strings))
def main():
parse_args(parse_env(set_defaults()))
return 0