diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index 4bd844ae0..2c9b4ae15 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -67,6 +67,8 @@ Fixed (#8679). - Added site-specific quirk for gitlab.gnome.org agressively blocking old Chromium versions (and thus QtWebEngine) (#8509). +- Using `:config-list-remove` with an invalid value for the respective option + type now corrently displays an error instead of crashing. [[v3.5.1]] v3.5.1 (2025-06-05) diff --git a/qutebrowser/config/configcommands.py b/qutebrowser/config/configcommands.py index 9012cc2c4..80ba23029 100644 --- a/qutebrowser/config/configcommands.py +++ b/qutebrowser/config/configcommands.py @@ -356,9 +356,8 @@ class ConfigCommands: raise cmdutils.CommandError(":config-list-remove can only be used " "for lists") - converted = opt.typ.valtype.from_str(value) - with self._handle_config_error(): + converted = opt.typ.valtype.from_str(value) option_value = self._config.get_mutable_obj(option) if converted not in option_value: diff --git a/tests/unit/config/test_configcommands.py b/tests/unit/config/test_configcommands.py index f9dca3e74..12554ec1b 100644 --- a/tests/unit/config/test_configcommands.py +++ b/tests/unit/config/test_configcommands.py @@ -315,9 +315,10 @@ class TestAdd: with pytest.raises(cmdutils.CommandError, match="Invalid value ''"): commands.config_list_add('content.blocking.whitelist', '') - # FIXME test value conversion for :list-add like in test_dict_add_value_type - # (once we have a List config option using a non-str type, or a way to - # dynamically add new option definitions). + def test_list_add_value_type(self, commands, config_stub): + commands.config_list_add("completion.web_history.exclude", "*") + value = config_stub.val.completion.web_history.exclude + assert value == [urlmatch.UrlPattern("*")] @pytest.mark.parametrize('value', ['test1', 'test2']) @pytest.mark.parametrize('temp', [True, False]) @@ -410,9 +411,16 @@ class TestRemove: match="#133742 is not in colors.completion.fg!"): commands.config_list_remove('colors.completion.fg', '#133742') - # FIXME test value conversion for :list-remove like in test_dict_add_value_type - # (once we have a List config option using a non-str type, or a way to - # dynamically add new option definitions). + def test_list_remove_value_type(self, commands, config_stub): + config_stub.val.completion.web_history.exclude = ["*"] + commands.config_list_remove("completion.web_history.exclude", "*") + assert not config_stub.val.completion.web_history.exclude + + def test_list_remove_invalid_value(self, commands, config_stub): + with pytest.raises( + cmdutils.CommandError, + match="Invalid value '::' - Pattern without host"): + commands.config_list_remove("completion.web_history.exclude", "::") @pytest.mark.parametrize('key', ['w', 'q']) @pytest.mark.parametrize('temp', [True, False])