1
0
mirror of https://github.com/wting/autojump synced 2024-09-28 05:50:47 +00:00

Merge pull request #184 from jsliang/master

Do not exit with error if current directory is the only match.

Closes #182.
This commit is contained in:
William Ting 2013-02-14 11:38:57 -08:00
commit 409b2ec84c

View File

@ -377,6 +377,7 @@ def find_matches(db, patterns, max_matches=1, ignore_case=False, fuzzy=False):
else: else:
return [] return []
current_dir_match = False
for path, _ in dirs: for path, _ in dirs:
found, tmp = True, path found, tmp = True, path
for n, p in enumerate(patterns): for n, p in enumerate(patterns):
@ -391,12 +392,18 @@ def find_matches(db, patterns, max_matches=1, ignore_case=False, fuzzy=False):
# avoid jumping to current directory # avoid jumping to current directory
# (call out to realpath this late to not stat all dirs) # (call out to realpath this late to not stat all dirs)
if current_dir == os.path.realpath(path): if current_dir == os.path.realpath(path):
current_dir_match = True
continue continue
if path not in results: if path not in results:
results.append(path) results.append(path)
if len(results) >= max_matches: if len(results) >= max_matches:
break break
# if current directory is the only match, add it to results
if len(results) == 0 and current_dir_match:
results.append(current_dir)
return results return results
def shell_utility(): def shell_utility():