diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-09-01 13:25:17 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-09-03 22:14:09 +0100 |
commit | 9404759ee12e38898d2002d1d5df09cb719e19ea (patch) | |
tree | 633493abb69cfa14ff2196565ae36ca8a59f20be | |
parent | 2d0d9baf55e9cbcc2c952fdc40dac25f50946017 (diff) |
fix: command completion with preceding spaces
-rw-r--r-- | alot/completion.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/alot/completion.py b/alot/completion.py index 02b33605..29af9d84 100644 --- a/alot/completion.py +++ b/alot/completion.py @@ -301,6 +301,13 @@ class CommandCompleter(Completer): self._pathcompleter = PathCompleter() def complete(self, line, pos): + # remember how many preceding space characters we see until the command + # string starts. We'll continue to complete from there on and will add + # these whitespaces again at the very end + whitespaceoffset = len(line) - len(line.lstrip()) + line = line[whitespaceoffset:] + pos = pos - whitespaceoffset + words = line.split(' ', 1) res = [] @@ -402,6 +409,7 @@ class CommandCompleter(Completer): # prepend cmd and correct position res = [('%s %s' % (cmd, t), p + len(cmd) + 1) for (t, p) in res] + res = [(' ' * whitespaceoffset + cmd, p + whitespaceoffset) for cmd, p in res] return res |