Avoid spurious exception printed to stderr when terminating a key sequence with an invalid key

This commit is contained in:
Kovid Goyal 2021-11-23 16:29:10 +05:30
parent 2ca13e886a
commit 9dbdd58311
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -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: