From 10a8a3f785f1c9c18734d3714e80957dda0b26e0 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 18 Dec 2012 17:14:53 +0100 Subject: [PATCH] Avoid file stats in find_matches for fuzzy=True, too --- bin/autojump | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bin/autojump b/bin/autojump index 0c1a440..17cca82 100755 --- a/bin/autojump +++ b/bin/autojump @@ -355,14 +355,21 @@ def find_matches(db, patterns, max_matches=1, ignore_case=False, fuzzy=False): end = d[0].split('/')[-1] # collisions: ignore lower weight paths - if end not in end_dirs and (os.path.exists(d[0]) or TESTING): - # avoid jumping to current directory - if current_dir == os.path.realpath(d[0]): - continue + if end not in end_dirs: end_dirs[end] = d[0] # find the first match (heighest weight) - found = get_close_matches(patterns[-1], end_dirs, 1, .6) + while True: + found = get_close_matches(patterns[-1], end_dirs, n=1, cutoff=.6) + if not found: + break + # avoid jumping to current directory + if (os.path.exists(found[0]) or TESTING) and \ + current_dir != os.path.realpath(found[0]): + break + # continue with the last found directory removed + del end_dirs[found[0]] + if found: found = found[0] results.append(end_dirs[found])