Fixed tab-completion for packages containing "-"

Also fix broken tab-completion after the first "/".
master
Niels Thykier 13 years ago
parent 4ff3af52ad
commit e71016c5a0

@ -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

@ -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:

Loading…
Cancel
Save