1
0
mirror of https://github.com/wting/autojump synced 2024-09-28 14:00:46 +00:00

Merge pull request #296 from blueyed/handle-empty-needle

Completion and jumping for empty needles
This commit is contained in:
William Ting 2014-06-28 12:18:58 -07:00
commit 17565a907d

View File

@ -193,9 +193,6 @@ def find_matches(entries, needles, check_entries=True):
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)
if tab_path:
@ -364,7 +361,7 @@ def main(args): # noqa
save(config, first(add_path(load(config), args.add)))
elif args.complete:
handle_tab_completion(
needle=first(sanitize(args.directory)),
needle=first(chain(sanitize(args.directory), [''])),
entries=entriefy(load(config)))
elif args.decrease:
data, entry = decrease_path(load(config), get_pwd(), args.decrease)
@ -382,8 +379,12 @@ def main(args): # noqa
elif args.stat:
print_stats(load(config), config['data_path'])
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
print_local('.')
['.'])))
else:
entries = entriefy(load(config))
needles = sanitize(args.directory)