From 75c996c13ee52eaedc57c5c67a5b9fd8e67d21e7 Mon Sep 17 00:00:00 2001 From: Jan Verbeek Date: Fri, 11 Nov 2016 02:45:59 +0100 Subject: [PATCH] Cancel register key input with escape --- qutebrowser/keyinput/modeparsers.py | 4 ++++ tests/end2end/features/keyinput.feature | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/qutebrowser/keyinput/modeparsers.py b/qutebrowser/keyinput/modeparsers.py index 6fa881ad7..25243b1be 100644 --- a/qutebrowser/keyinput/modeparsers.py +++ b/qutebrowser/keyinput/modeparsers.py @@ -290,6 +290,10 @@ class RegisterKeyParser(keyparser.BaseKeyParser): Return: True if event has been handled, False otherwise. """ + if e.key() == Qt.Key_Escape: + self.request_leave.emit(self._mode, "register key cancelled", True) + return True + if utils.keyevent_to_string(e) is None: # this is a modifier key, let it pass and keep going return False diff --git a/tests/end2end/features/keyinput.feature b/tests/end2end/features/keyinput.feature index 6b671825d..1e94b10ac 100644 --- a/tests/end2end/features/keyinput.feature +++ b/tests/end2end/features/keyinput.feature @@ -255,3 +255,8 @@ Feature: Keyboard input And I press the key "a" And I wait for "hints: *" in the log Then no crash should happen + + Scenario: Cancelling key input + When I run :record-macro + And I press the key "" + Then "Leaving mode KeyMode.record_macro (reason: register key cancelled)" should be logged