mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-05-28 19:01:35 +00:00
Fixed tab-completion for packages containing "-"
Also fix broken tab-completion after the first "/".
This commit is contained in:
parent
27ddc8a9e7
commit
ced28100fb
@ -2505,6 +2505,9 @@ class Britney:
|
|||||||
|
|
||||||
readline.parse_and_bind('tab: complete')
|
readline.parse_and_bind('tab: complete')
|
||||||
readline.set_completer(Completer(self).completer)
|
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:
|
while True:
|
||||||
# read the command from the command line
|
# 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)]
|
self.matches = [x for x in self.cmds if x.startswith(text)]
|
||||||
else:
|
else:
|
||||||
# complete pkg/[arch/]version
|
# complete pkg/[arch/]version
|
||||||
|
prefix = ''
|
||||||
|
if len(text) > 0 and text[0] == '-':
|
||||||
|
text = text[1:]
|
||||||
|
prefix = '-'
|
||||||
start = bisect.bisect_left(self.packages, text)
|
start = bisect.bisect_left(self.packages, text)
|
||||||
while start < len(self.packages):
|
while start < len(self.packages):
|
||||||
if not self.packages[start].startswith(text):
|
if not self.packages[start].startswith(text):
|
||||||
break
|
break
|
||||||
self.matches.append(self.packages[start])
|
self.matches.append(prefix + self.packages[start])
|
||||||
start += 1
|
start += 1
|
||||||
|
|
||||||
if len(self.matches) > state:
|
if len(self.matches) > state:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user