Fix unbinding default keys twice
When doing :unbind with a default keybinding the first time, it gets inserted into bindings.commands with None as value. When then doing :unbind a second time, instead of just leaving that None value as-is, we removed it again (because it got treated as a custom binding). Fixes #3162
This commit is contained in:
parent
b8e1ed752f
commit
5689a3c0dc
@ -198,7 +198,7 @@ class KeyConfig:
|
||||
|
||||
bindings_commands = self._config.get_obj('bindings.commands')
|
||||
|
||||
if key in val.bindings.commands[mode]:
|
||||
if val.bindings.commands[mode].get(key, None) is not None:
|
||||
# In custom bindings -> remove it
|
||||
del bindings_commands[mode][key]
|
||||
elif key in val.bindings.default[mode]:
|
||||
|
@ -269,6 +269,22 @@ class TestKeyConfig:
|
||||
match="Can't find binding 'foobar' in normal mode"):
|
||||
key_config_stub.unbind('foobar', mode='normal')
|
||||
|
||||
def test_unbound_twice(self, key_config_stub, config_stub, no_bindings):
|
||||
"""Try unbinding an already-unbound default key.
|
||||
|
||||
For custom-bound keys (in bindings.commands), it's okay to display an
|
||||
error, as this isn't something you'd do in e.g a config.py anyways.
|
||||
|
||||
https://github.com/qutebrowser/qutebrowser/issues/3162
|
||||
"""
|
||||
config_stub.val.bindings.default = {'normal': {'a': 'nop'}}
|
||||
config_stub.val.bindings.commands = no_bindings
|
||||
|
||||
key_config_stub.unbind('a')
|
||||
assert key_config_stub.get_command('a', mode='normal') is None
|
||||
key_config_stub.unbind('a')
|
||||
assert key_config_stub.get_command('a', mode='normal') is None
|
||||
|
||||
|
||||
class TestConfig:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user