From 26df57a1c7841995917f80ff6f72dccbaf1ecbf4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 18 May 2018 21:28:43 +0530 Subject: [PATCH] More elegant handling for pressing enter with no valid current input in the hints kitten --- kittens/hints/main.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/kittens/hints/main.py b/kittens/hints/main.py index 4955b2a67..88cd4c41f 100644 --- a/kittens/hints/main.py +++ b/kittens/hints/main.py @@ -128,9 +128,15 @@ def on_key(self, key_event): self.current_text = None self.draw_screen() elif key_event is enter_key and self.current_input: - idx = decode_hint(self.current_input) - self.chosen = self.index_map[idx].text - self.quit_loop(0) + try: + idx = decode_hint(self.current_input) + self.chosen = self.index_map[idx].text + except Exception: + self.current_input = '' + self.current_text = None + self.draw_screen() + else: + self.quit_loop(0) elif key_event.key is ESCAPE: self.quit_loop(1)