diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 8d93a2344..c7826aef2 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -275,14 +275,17 @@ class ConfigCommands: # Use the next valid value from values, or the first if the current # value does not appear in the list - old_value = self._config.get_str(option) + old_value = self._config.get_obj(option, mutable=False) + opt = self._config.get_opt(option) + values = [opt.typ.from_str(val) for val in values] + try: - idx = values.index(str(old_value)) + idx = values.index(old_value) idx = (idx + 1) % len(values) value = values[idx] except ValueError: value = values[0] - self._config.set_str(option, value, save_yaml=not temp) + self._config.set_obj(option, value, save_yaml=not temp) @contextlib.contextmanager def _handle_config_error(self): diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index 24c6814b5..949064bc9 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -439,6 +439,18 @@ class TestSetConfigCommand: assert config_stub.get(opt) == expected assert config_stub._yaml[opt] == expected + def test_cycling_different_representation(self, commands, config_stub): + """When using a different representation, cycling should work. + + For example, we use [foo] which is represented as ["foo"]. + """ + opt = 'qt_args' + config_stub.set_obj(opt, ['foo']) + commands.set(0, opt, '[foo]', '[bar]') + assert config_stub.get(opt) == ['bar'] + commands.set(0, opt, '[foo]', '[bar]') + assert config_stub.get(opt) == ['foo'] + class TestBindConfigCommand: