summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qutebrowser/config/configtypes.py3
-rw-r--r--tests/unit/config/test_config.py18
2 files changed, 21 insertions, 0 deletions
diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py
index 71ff898ea..01bcc5eb0 100644
--- a/qutebrowser/config/configtypes.py
+++ b/qutebrowser/config/configtypes.py
@@ -1650,6 +1650,9 @@ class Key(BaseType):
"""A name of a key."""
+ def from_obj(self, value):
+ return str(keyutils.KeySequence.parse(value))
+
def to_py(self, value):
self._basic_py_validation(value, str)
if not value:
diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py
index 9104c0f53..e1ef7ef94 100644
--- a/tests/unit/config/test_config.py
+++ b/tests/unit/config/test_config.py
@@ -339,6 +339,24 @@ class TestKeyConfig:
key_config_stub.unbind(seq)
assert key_config_stub.get_command(seq, mode='normal') is None
+ def test_unbind_old_syntax(self, yaml_config_stub, key_config_stub,
+ config_stub):
+ """Test unbinding bindings added before the keybinding refactoring.
+
+ We used to normalize keys differently, so we can have <ctrl+q> in the
+ config.
+
+ See https://github.com/qutebrowser/qutebrowser/issues/3699
+ """
+ bindings = {'normal': {'<ctrl+q>': 'nop'}}
+ yaml_config_stub.set_obj('bindings.commands', bindings)
+ config_stub.read_yaml()
+
+ key_config_stub.unbind(keyutils.KeySequence.parse('<ctrl+q>'),
+ save_yaml=True)
+
+ assert config.instance.get_obj('bindings.commands') == {'normal': {}}
+
def test_empty_command(self, key_config_stub):
"""Try binding a key to an empty command."""
message = "Can't add binding 'x' with empty command in normal mode"