From df03099468e2c484a469c4fcafe865ca5e04d4c7 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 12 Jan 2016 18:51:12 +0100 Subject: [PATCH] Fix completion for String config type. Since 2a705e2eb62d5f2e8052f036c8b520203b51f537 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. --- CHANGELOG.asciidoc | 5 +++++ qutebrowser/config/configtypes.py | 5 ++++- tests/unit/config/test_configtypes.py | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 5f81abe61..b473fee68 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -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 ------ diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index bd9af1f33..dbcb13fa5 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -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): diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py index d2dd2886b..b746ba035 100644 --- a/tests/unit/config/test_configtypes.py +++ b/tests/unit/config/test_configtypes.py @@ -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: