only show rightmost completion in nested attrs

only prompt_toolkit so far
This commit is contained in:
Gil Forsyth 2016-08-25 09:20:16 -04:00
parent 7a689bbbcb
commit d47ac71e6b
2 changed files with 4 additions and 1 deletions

View file

@ -106,7 +106,8 @@ def attr_complete(prefix, ctx, filter_func):
rpl = opt
# note that prefix[:prelen-len(attr)] != prefix[:-len(attr)]
# when len(attr) == 0.
comp = prefix[:prelen - len(attr)] + rpl
# comp = prefix[:prelen - len(attr)] + rpl
comp = rpl
attrs.add(comp)
return attrs

View file

@ -41,6 +41,8 @@ class PromptToolkitCompleter(Completer):
elif len(os.path.commonprefix(completions)) <= len(prefix):
self.reserve_space()
for comp in completions:
prefix = prefix.rsplit('.', 1)[-1]
l = len(prefix) if prefix in comp else 0
yield Completion(comp, -l)
def reserve_space(self):