From 817152821576ddf5385aa0797a444fc60b6b23e4 Mon Sep 17 00:00:00 2001 From: Ye Date: Mon, 22 Jan 2018 16:12:55 -0800 Subject: [PATCH] Fix a offset by 1 error For a concrete example, when I used the autojump tool, I often saw this off-by-1 error: $ j data__ data__1__/Users/ye_wang/data/src/test data__2__/Users/ye_wang/dataeng/src data__3__/Users/ye_wang/dataeng/java/com $ j data__2 /Users/ye_wang/dataeng/java/com This PR fixes the above issue. --- bin/autojump | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/autojump b/bin/autojump index e7b061d..523cb88 100755 --- a/bin/autojump +++ b/bin/autojump @@ -210,6 +210,9 @@ def handle_tab_completion(needle, entries): if tab_path: print_local(tab_path) elif tab_index: + # As our display menu shows the starting index from 1, we want to reduce the user-input + # index by 1. + tab_index = max(0, tab_index - 1) get_ith_path = lambda i, iterable: last(take(i, iterable)).path print_local(get_ith_path( tab_index,