configcommands: Fix :config-list-remove with invalid value

This commit is contained in:
Florian Bruhin 2025-10-12 14:53:45 +02:00
parent 9d80bc2076
commit 621f20adb3
3 changed files with 17 additions and 8 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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])