Change hard-coded escape to leave-mode binding

This commit is contained in:
Jan Verbeek 2016-11-14 23:28:38 +01:00
parent 75c996c13e
commit f0d215e07a
2 changed files with 5 additions and 8 deletions

View File

@ -267,7 +267,7 @@ class CaretKeyParser(keyparser.CommandKeyParser):
self.read_config('caret') self.read_config('caret')
class RegisterKeyParser(keyparser.BaseKeyParser): class RegisterKeyParser(keyparser.CommandKeyParser):
"""KeyParser for modes that record a register key. """KeyParser for modes that record a register key.
@ -280,6 +280,7 @@ class RegisterKeyParser(keyparser.BaseKeyParser):
super().__init__(win_id, parent, supports_count=False, super().__init__(win_id, parent, supports_count=False,
supports_chains=False) supports_chains=False)
self._mode = mode self._mode = mode
self.read_config('register')
def handle(self, e): def handle(self, e):
"""Override handle to always match the next key and use the register. """Override handle to always match the next key and use the register.
@ -290,8 +291,8 @@ class RegisterKeyParser(keyparser.BaseKeyParser):
Return: Return:
True if event has been handled, False otherwise. True if event has been handled, False otherwise.
""" """
if e.key() == Qt.Key_Escape:
self.request_leave.emit(self._mode, "register key cancelled", True) if super().handle(e):
return True return True
if utils.keyevent_to_string(e) is None: if utils.keyevent_to_string(e) is None:
@ -327,7 +328,3 @@ class RegisterKeyParser(keyparser.BaseKeyParser):
def on_keyconfig_changed(self, mode): def on_keyconfig_changed(self, mode):
"""RegisterKeyParser has no config section (no bindable keys).""" """RegisterKeyParser has no config section (no bindable keys)."""
pass pass
def execute(self, cmdstr, _keytype, count=None):
"""Should never be called on RegisterKeyParser."""
assert False

View File

@ -259,4 +259,4 @@ Feature: Keyboard input
Scenario: Cancelling key input Scenario: Cancelling key input
When I run :record-macro When I run :record-macro
And I press the key "<Escape>" And I press the key "<Escape>"
Then "Leaving mode KeyMode.record_macro (reason: register key cancelled)" should be logged Then "Leaving mode KeyMode.record_macro (reason: leave current)" should be logged