mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
Merge pull request #296 from blueyed/handle-empty-needle
Completion and jumping for empty needles
This commit is contained in:
commit
17565a907d
11
bin/autojump
11
bin/autojump
@ -193,9 +193,6 @@ def find_matches(entries, needles, check_entries=True):
|
|||||||
|
|
||||||
|
|
||||||
def handle_tab_completion(needle, entries):
|
def handle_tab_completion(needle, entries):
|
||||||
if not needle:
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
tab_needle, tab_index, tab_path = get_tab_entry_info(needle, TAB_SEPARATOR)
|
tab_needle, tab_index, tab_path = get_tab_entry_info(needle, TAB_SEPARATOR)
|
||||||
|
|
||||||
if tab_path:
|
if tab_path:
|
||||||
@ -364,7 +361,7 @@ def main(args): # noqa
|
|||||||
save(config, first(add_path(load(config), args.add)))
|
save(config, first(add_path(load(config), args.add)))
|
||||||
elif args.complete:
|
elif args.complete:
|
||||||
handle_tab_completion(
|
handle_tab_completion(
|
||||||
needle=first(sanitize(args.directory)),
|
needle=first(chain(sanitize(args.directory), [''])),
|
||||||
entries=entriefy(load(config)))
|
entries=entriefy(load(config)))
|
||||||
elif args.decrease:
|
elif args.decrease:
|
||||||
data, entry = decrease_path(load(config), get_pwd(), args.decrease)
|
data, entry = decrease_path(load(config), get_pwd(), args.decrease)
|
||||||
@ -382,8 +379,12 @@ def main(args): # noqa
|
|||||||
elif args.stat:
|
elif args.stat:
|
||||||
print_stats(load(config), config['data_path'])
|
print_stats(load(config), config['data_path'])
|
||||||
elif not args.directory:
|
elif not args.directory:
|
||||||
|
# Return best match.
|
||||||
|
entries = entriefy(load(config))
|
||||||
|
print_local(first(chain(
|
||||||
|
imap(attrgetter('path'), find_matches(entries, [''])),
|
||||||
# always return a path to calling shell functions
|
# always return a path to calling shell functions
|
||||||
print_local('.')
|
['.'])))
|
||||||
else:
|
else:
|
||||||
entries = entriefy(load(config))
|
entries = entriefy(load(config))
|
||||||
needles = sanitize(args.directory)
|
needles = sanitize(args.directory)
|
||||||
|
Loading…
Reference in New Issue
Block a user