Fix completion for String config type.

Since 2a705e2eb6 non-specialized config types are
String. However, String had an overloaded complete() which defaulted to
returning None.

Now we use the normal complete() which relies on valid_values if completions
isn't given instead.

Fixes #1223.
This commit is contained in:
Florian Bruhin 2016-01-12 18:51:12 +01:00
parent 22d255f49f
commit df03099468
3 changed files with 18 additions and 1 deletions

View File

@ -23,6 +23,11 @@ Added
- New `--quiet` argument for the `:debug-pyeval` command to not open a tab with
the results. Note `:debug-pyeval` is still only intended for debugging.
Fixed
~~~~~
- Fixed completion for various config values when using `:set`.
v0.5.0
------

View File

@ -270,7 +270,10 @@ class String(BaseType):
"long!".format(self.maxlen))
def complete(self):
return self._completions
if self._completions is not None:
return self._completions
else:
return super().complete()
class List(BaseType):

View File

@ -335,6 +335,15 @@ class TestString:
def test_complete(self, klass, value):
assert klass(completions=value).complete() == value
@pytest.mark.parametrize('valid_values, expected', [
(configtypes.ValidValues('one', 'two'),
[('one', ''), ('two', '')]),
(configtypes.ValidValues(('1', 'one'), ('2', 'two')),
[('1', 'one'), ('2', 'two')]),
])
def test_complete_valid_values(self, klass, valid_values, expected):
assert klass(valid_values=valid_values).complete() == expected
class TestList: