diff --git a/qutebrowser/config/parsers/keyconf.py b/qutebrowser/config/parsers/keyconf.py index 71ca14ceb..7c00b9584 100644 --- a/qutebrowser/config/parsers/keyconf.py +++ b/qutebrowser/config/parsers/keyconf.py @@ -154,7 +154,7 @@ class KeyConfigParser(QObject): @cmdutils.argument('win_id', win_id=True) @cmdutils.argument('key', completion=usertypes.Completion.empty) @cmdutils.argument('command', completion=usertypes.Completion.command) - def bind(self, key, win_id, command=None, *, mode=None, force=False): + def bind(self, key, win_id, command=None, *, mode='normal', force=False): """Bind a key to a command. Args: @@ -165,8 +165,9 @@ class KeyConfigParser(QObject): (default: `normal`). force: Rebind the key if it is already bound. """ - if mode is None: - mode = 'normal' + if utils.is_special_key(key): + # , , and should be considered equivalent + key = key.lower() if command is None: cmd = self.get_bindings_for(mode).get(key, None) @@ -198,7 +199,7 @@ class KeyConfigParser(QObject): self._mark_config_dirty() @cmdutils.register(instance='key-config') - def unbind(self, key, mode=None): + def unbind(self, key, mode='normal'): """Unbind a keychain. Args: @@ -206,8 +207,10 @@ class KeyConfigParser(QObject): mode: A comma-separated list of modes to unbind the key in (default: `normal`). """ - if mode is None: - mode = 'normal' + if utils.is_special_key(key): + # , , and should be considered equivalent + key = key.lower() + mode = self._normalize_sectname(mode) for m in mode.split(','): if m not in configdata.KEY_DATA: @@ -377,6 +380,9 @@ class KeyConfigParser(QObject): def _add_binding(self, sectname, keychain, command, *, force=False): """Add a new binding from keychain to command in section sectname.""" + if utils.is_special_key(keychain): + # , , and should be considered equivalent + keychain = keychain.lower() log.keyboard.vdebug("Adding binding {} -> {} in mode {}.".format( keychain, command, sectname)) if sectname not in self.keybindings: diff --git a/tests/end2end/features/keyinput.feature b/tests/end2end/features/keyinput.feature index 4385c2357..b2fa4729c 100644 --- a/tests/end2end/features/keyinput.feature +++ b/tests/end2end/features/keyinput.feature @@ -45,6 +45,22 @@ Feature: Keyboard input And I run :bind --mode=caret test08 Then the message "test08 is bound to 'message-info bar' in caret mode" should be shown + Scenario: Binding special keys with differing case (issue 1544) + When I run :bind message-info test01 + And I run :bind message-info test01 + Then the error "Duplicate keychain - use --force to override!" should be shown + + Scenario: Print a special binding with differing case (issue 1544) + When I run :bind message-info foo + And I run :bind + Then the message " is bound to 'message-info foo' in normal mode" should be shown + + Scenario: Overriding a special binding with differing case (issue 816) + When I run :bind message-info foo + And I run :bind --force message-info bar + And I run :bind + Then the message " is bound to 'message-info bar' in normal mode" should be shown + # :unbind Scenario: Binding and unbinding a keychain @@ -67,6 +83,12 @@ Feature: Keyboard input Then "No binding found for o." should be logged # maybe check it's unbound in the config? + Scenario: Binding and unbinding a special keychain with differing case (issue 1544) + When I run :bind message-error test09 + And I run :unbind + When I run :bind + Then the message " is unbound in normal mode" should be shown + # :clear-keychain Scenario: Clearing the keychain