From 400cd62613192a51240edc06923ce6ff0218d19a Mon Sep 17 00:00:00 2001 From: William Ting Date: Tue, 14 May 2013 21:58:43 -0500 Subject: [PATCH] simplify tab completion --- bin/autojump | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/autojump b/bin/autojump index 355e469..c82949e 100755 --- a/bin/autojump +++ b/bin/autojump @@ -467,13 +467,16 @@ def main(): patterns = [unico('')] # check for tab completion - tab_choice = -1 - tab_match = re.search(config['separator']+"([0-9]+)", patterns[-1]) - if tab_match: # user has selected a tab completion entry + tab_choice = None + tab_match = re.search(sep+'([0-9]+)', patterns[-1]) + + # user has selected a tab completion entry + if tab_match: tab_choice = int(tab_match.group(1)) - patterns[-1] = re.sub(config['separator']+"[0-9]+.*", "", patterns[-1]) - else: # user hasn't selected a tab completion, display choices again - tab_match = re.match("(.*)"+config['separator'], patterns[-1]) + patterns[-1] = re.sub(sep+'[0-9]+.*', '', patterns[-1]) + # user hasn't selected a tab completion, display choices again + else: + tab_match = re.match('(.*)'+sep, patterns[-1]) if tab_match: patterns[-1] = tab_match.group(1)