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:
parent
22d255f49f
commit
df03099468
@ -23,6 +23,11 @@ Added
|
|||||||
- New `--quiet` argument for the `:debug-pyeval` command to not open a tab with
|
- 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.
|
the results. Note `:debug-pyeval` is still only intended for debugging.
|
||||||
|
|
||||||
|
Fixed
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
- Fixed completion for various config values when using `:set`.
|
||||||
|
|
||||||
v0.5.0
|
v0.5.0
|
||||||
------
|
------
|
||||||
|
|
||||||
|
@ -270,7 +270,10 @@ class String(BaseType):
|
|||||||
"long!".format(self.maxlen))
|
"long!".format(self.maxlen))
|
||||||
|
|
||||||
def complete(self):
|
def complete(self):
|
||||||
|
if self._completions is not None:
|
||||||
return self._completions
|
return self._completions
|
||||||
|
else:
|
||||||
|
return super().complete()
|
||||||
|
|
||||||
|
|
||||||
class List(BaseType):
|
class List(BaseType):
|
||||||
|
@ -335,6 +335,15 @@ class TestString:
|
|||||||
def test_complete(self, klass, value):
|
def test_complete(self, klass, value):
|
||||||
assert klass(completions=value).complete() == 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:
|
class TestList:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user