From ced28100fb9220bd49d0199ad6478cd824db7542 Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Sat, 22 Oct 2011 14:09:35 +0200 Subject: [PATCH] Fixed tab-completion for packages containing "-" Also fix broken tab-completion after the first "/". --- britney.py | 3 +++ completer.py | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/britney.py b/britney.py index 71cdc54..292dab3 100755 --- a/britney.py +++ b/britney.py @@ -2505,6 +2505,9 @@ class Britney: readline.parse_and_bind('tab: complete') readline.set_completer(Completer(self).completer) + # Package names can contain "-" and we use "/" in our presentation of them as well, + # so ensure readline does not split on these characters. + readline.set_completer_delims(readline.get_completer_delims().replace('-', '').replace('/', '')) while True: # read the command from the command line diff --git a/completer.py b/completer.py index be86744..ea09f6a 100644 --- a/completer.py +++ b/completer.py @@ -45,11 +45,15 @@ class Completer: self.matches = [x for x in self.cmds if x.startswith(text)] else: # complete pkg/[arch/]version + prefix = '' + if len(text) > 0 and text[0] == '-': + text = text[1:] + prefix = '-' start = bisect.bisect_left(self.packages, text) while start < len(self.packages): if not self.packages[start].startswith(text): break - self.matches.append(self.packages[start]) + self.matches.append(prefix + self.packages[start]) start += 1 if len(self.matches) > state: