mirror of
https://github.com/wting/autojump
synced 2025-06-13 12:54:07 +00:00
Merge 10a8a3f785
into a99183bf8b
This commit is contained in:
commit
d4291a5e74
23
bin/autojump
23
bin/autojump
@ -355,11 +355,21 @@ def find_matches(db, patterns, max_matches=1, ignore_case=False, fuzzy=False):
|
|||||||
end = d[0].split('/')[-1]
|
end = d[0].split('/')[-1]
|
||||||
|
|
||||||
# collisions: ignore lower weight paths
|
# collisions: ignore lower weight paths
|
||||||
if end not in end_dirs and (os.path.exists(d[0]) or TESTING):
|
if end not in end_dirs:
|
||||||
end_dirs[end] = d[0]
|
end_dirs[end] = d[0]
|
||||||
|
|
||||||
# find the first match (heighest weight)
|
# 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:
|
if found:
|
||||||
found = found[0]
|
found = found[0]
|
||||||
results.append(end_dirs[found])
|
results.append(end_dirs[found])
|
||||||
@ -368,10 +378,6 @@ def find_matches(db, patterns, max_matches=1, ignore_case=False, fuzzy=False):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
for path, _ in dirs:
|
for path, _ in dirs:
|
||||||
# avoid jumping to current directory
|
|
||||||
if current_dir == decode(os.path.realpath(path)) :
|
|
||||||
continue
|
|
||||||
|
|
||||||
found, tmp = True, path
|
found, tmp = True, path
|
||||||
for n, p in enumerate(patterns):
|
for n, p in enumerate(patterns):
|
||||||
# for single/last pattern, only check end of path
|
# for single/last pattern, only check end of path
|
||||||
@ -382,6 +388,11 @@ def find_matches(db, patterns, max_matches=1, ignore_case=False, fuzzy=False):
|
|||||||
if not found: break
|
if not found: break
|
||||||
|
|
||||||
if found and (os.path.exists(path) or TESTING):
|
if found and (os.path.exists(path) or TESTING):
|
||||||
|
# avoid jumping to current directory
|
||||||
|
# (call out to realpath this late to not stat all dirs)
|
||||||
|
if current_dir == os.path.realpath(path):
|
||||||
|
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:
|
||||||
|
Loading…
Reference in New Issue
Block a user