From 9dbdd58311340dfe2596c427d095b57288e6ad0a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 23 Nov 2021 16:29:10 +0530 Subject: [PATCH] Avoid spurious exception printed to stderr when terminating a key sequence with an invalid key --- kitty/boss.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/kitty/boss.py b/kitty/boss.py index 82ed03cb2..abbef093a 100755 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -1133,14 +1133,15 @@ class Boss: ''') def combine(self, actions: Tuple[KeyAction, ...], window_for_dispatch: Optional[Window] = None, dispatch_type: str = 'KeyPress') -> bool: consumed = False - try: - if self.dispatch_action(actions[0], window_for_dispatch, dispatch_type): + if actions: + try: + if self.dispatch_action(actions[0], window_for_dispatch, dispatch_type): + consumed = True + if len(actions) > 1: + self.drain_actions(list(actions[1:]), window_for_dispatch, dispatch_type) + except Exception as e: + self.show_error('Key action failed', f'{actions[0].pretty()}\n{e}') consumed = True - if len(actions) > 1: - self.drain_actions(list(actions[1:]), window_for_dispatch, dispatch_type) - except Exception as e: - self.show_error('Key action failed', f'{actions[0].pretty()}\n{e}') - consumed = True return consumed def on_focus(self, os_window_id: int, focused: bool) -> None: