mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
minor reorganization tweaks
This commit is contained in:
parent
7343ef1825
commit
a96d1bca9d
18
bin/autojump
18
bin/autojump
@ -274,35 +274,31 @@ def shell_utility():
|
|||||||
# FIXME: disabled until tab completion is fixed on the shell side
|
# FIXME: disabled until tab completion is fixed on the shell side
|
||||||
# if match_last(patterns): return True
|
# if match_last(patterns): return True
|
||||||
|
|
||||||
#userchoice is i if the pattern is __pattern__i, otherwise -1
|
|
||||||
userchoice = -1
|
|
||||||
results = []
|
|
||||||
|
|
||||||
#check for ongoing completion, and act accordingly
|
#check for ongoing completion, and act accordingly
|
||||||
|
userchoice = -1
|
||||||
endmatch = re.search(COMPLETION_SEPARATOR+"([0-9]+)", patterns[-1])
|
endmatch = re.search(COMPLETION_SEPARATOR+"([0-9]+)", patterns[-1])
|
||||||
if endmatch: #user has selected a completion
|
if endmatch: #user has selected a completion
|
||||||
userchoice = int(endmatch.group(1))
|
userchoice = int(endmatch.group(1))
|
||||||
patterns[-1] = re.sub(COMPLETION_SEPARATOR+"[0-9]+.*",
|
patterns[-1] = re.sub(COMPLETION_SEPARATOR+"[0-9]+.*", "", patterns[-1])
|
||||||
"", patterns[-1])
|
|
||||||
else: #user hasn't selected a completion, display the same choices again
|
else: #user hasn't selected a completion, display the same choices again
|
||||||
endmatch = re.match("(.*)"+COMPLETION_SEPARATOR, patterns[-1])
|
endmatch = re.match("(.*)"+COMPLETION_SEPARATOR, patterns[-1])
|
||||||
if endmatch: patterns[-1] = endmatch.group(1)
|
if endmatch: patterns[-1] = endmatch.group(1)
|
||||||
|
|
||||||
dirs = list(db.data.items())
|
|
||||||
dirs.sort(key=itemgetter(1), reverse=True)
|
|
||||||
if ARGS.complete or userchoice != -1:
|
if ARGS.complete or userchoice != -1:
|
||||||
max_matches = 9
|
max_matches = 9
|
||||||
else:
|
else:
|
||||||
max_matches = 1
|
max_matches = 1
|
||||||
|
|
||||||
# Don't jump to the current directory
|
|
||||||
try:
|
try:
|
||||||
current_dir = decode(os.path.realpath(os.curdir))
|
current_dir = decode(os.path.realpath(os.curdir))
|
||||||
#Sometimes the current path doesn't exist anymore.
|
|
||||||
#In that case, jump if possible.
|
|
||||||
except OSError:
|
except OSError:
|
||||||
current_dir = None
|
current_dir = None
|
||||||
|
|
||||||
|
results = []
|
||||||
|
dirs = list(db.data.items())
|
||||||
|
dirs.sort(key=itemgetter(1), reverse=True)
|
||||||
find_matches(dirs, patterns, results, False, max_matches, current_dir)
|
find_matches(dirs, patterns, results, False, max_matches, current_dir)
|
||||||
|
|
||||||
# If not found, try ignoring case.
|
# If not found, try ignoring case.
|
||||||
# On completion always show all results
|
# On completion always show all results
|
||||||
if ARGS.complete or not results:
|
if ARGS.complete or not results:
|
||||||
|
Loading…
Reference in New Issue
Block a user