unicode_input kitten: Fix a regression that broke using indices to select recently used symbols.

This commit is contained in:
Kovid Goyal 2019-06-17 07:11:07 +05:30
parent 721beb9202
commit 38bc90f724
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 23 additions and 19 deletions

View File

@ -15,6 +15,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- When piping data to a child in the pipe command do it in a thread so as not - When piping data to a child in the pipe command do it in a thread so as not
to block the UI (:iss:`1708`) to block the UI (:iss:`1708`)
- unicode_input kitten: Fix a regression that broke using indices to select
recently used symbols.
0.14.2 [2019-06-09] 0.14.2 [2019-06-09]
--------------------- ---------------------

View File

@ -240,10 +240,9 @@ class Table:
def is_index(w): def is_index(w):
try: with suppress(Exception):
int(w.lstrip(INDEX_CHAR), 16) int(w.lstrip(INDEX_CHAR), 16)
return True return True
except Exception:
return False return False
@ -295,9 +294,10 @@ class UnicodeInput(Handler):
self.current_char = None self.current_char = None
if self.mode is HEX: if self.mode is HEX:
with suppress(Exception): with suppress(Exception):
if self.line_edit.current_input.startswith(INDEX_CHAR) and len(self.line_edit.current_input) > 1: if self.line_edit.current_input.startswith(INDEX_CHAR):
if len(self.line_edit.current_input) > 1:
self.current_char = chr(self.table.codepoint_at_hint(self.line_edit.current_input[1:])) self.current_char = chr(self.table.codepoint_at_hint(self.line_edit.current_input[1:]))
else: elif self.line_edit.current_input:
code = int(self.line_edit.current_input, 16) code = int(self.line_edit.current_input, 16)
self.current_char = chr(code) self.current_char = chr(code)
elif self.mode is NAME: elif self.mode is NAME:
@ -392,7 +392,8 @@ class UnicodeInput(Handler):
try: try:
val = int(self.line_edit.current_input, 16) val = int(self.line_edit.current_input, 16)
except Exception: except Exception:
return pass
else:
if key_event.key is TAB: if key_event.key is TAB:
self.line_edit.current_input = hex(val + 0x10)[2:] self.line_edit.current_input = hex(val + 0x10)[2:]
self.refresh() self.refresh()