From 89c62377da0bb56f21350453a3d30caa08088773 Mon Sep 17 00:00:00 2001 From: purxiz Date: Wed, 6 Jan 2021 13:24:38 -0600 Subject: [PATCH] fix type error I moved the location of the check for an overflowing index to avoid a type error that was revealed by mypy. I also think this is a better place to put it from a code standpoint in general... --- kittens/unicode_input/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kittens/unicode_input/main.py b/kittens/unicode_input/main.py index e3395bff4..aeabc7a30 100644 --- a/kittens/unicode_input/main.py +++ b/kittens/unicode_input/main.py @@ -175,7 +175,7 @@ class Table: self.codepoints = codepoints self.mode = mode self.layout_dirty = True - self.current_idx = current_idx + self.current_idx = current_idx if current_idx < len(codepoints) else 0 def codepoint_at_hint(self, hint: str) -> int: return self.codepoints[decode_hint(hint)] @@ -330,7 +330,7 @@ class UnicodeInput(Handler): codepoints = codepoints_matching_search(tuple(words)) if q != self.last_updated_code_point_at: self.last_updated_code_point_at = q - self.table.set_codepoints(codepoints or [], self.mode, iindex_word if iindex_word < len(codepoints) else 0) + self.table.set_codepoints(codepoints or [], self.mode, iindex_word) def update_current_char(self) -> None: self.update_codepoints()