diff --git a/docs/changelog.rst b/docs/changelog.rst index 3573b98b1..8c6d50813 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -15,6 +15,9 @@ To update |kitty|, :doc:`follow the instructions `. - When piping data to a child in the pipe command do it in a thread so as not 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] --------------------- diff --git a/kittens/unicode_input/main.py b/kittens/unicode_input/main.py index cf2a6b25f..47ccdfe09 100644 --- a/kittens/unicode_input/main.py +++ b/kittens/unicode_input/main.py @@ -240,11 +240,10 @@ class Table: def is_index(w): - try: + with suppress(Exception): int(w.lstrip(INDEX_CHAR), 16) return True - except Exception: - return False + return False class UnicodeInput(Handler): @@ -295,9 +294,10 @@ class UnicodeInput(Handler): self.current_char = None if self.mode is HEX: with suppress(Exception): - if self.line_edit.current_input.startswith(INDEX_CHAR) and len(self.line_edit.current_input) > 1: - self.current_char = chr(self.table.codepoint_at_hint(self.line_edit.current_input[1:])) - else: + 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:])) + elif self.line_edit.current_input: code = int(self.line_edit.current_input, 16) self.current_char = chr(code) elif self.mode is NAME: @@ -392,19 +392,20 @@ class UnicodeInput(Handler): try: val = int(self.line_edit.current_input, 16) except Exception: - return - if key_event.key is TAB: - self.line_edit.current_input = hex(val + 0x10)[2:] - self.refresh() - return - if key_event.key is UP: - self.line_edit.current_input = hex(val + 1)[2:] - self.refresh() - return - if key_event.key is DOWN: - self.line_edit.current_input = hex(val - 1)[2:] - self.refresh() - return + pass + else: + if key_event.key is TAB: + self.line_edit.current_input = hex(val + 0x10)[2:] + self.refresh() + return + if key_event.key is UP: + self.line_edit.current_input = hex(val + 1)[2:] + self.refresh() + return + if key_event.key is DOWN: + self.line_edit.current_input = hex(val - 1)[2:] + self.refresh() + return if self.mode is NAME and key_event.type is not RELEASE and not key_event.mods: if key_event.key is TAB: if key_event.mods == SHIFT: