From 7c52dd2bd85da317ae3cad2c0d78a3b6f08a7787 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Mon, 2 Sep 2019 23:04:10 +0200 Subject: [PATCH] Fix update_encoding() not filtering GLFW_KEY_LAST_PRINTABLE b3b830bb5ffb8f42d5e2367e5aab03579be3a45f did not actually make `update_encoding()` filter `GLFW_KEY_LAST_PRINTABLE` because `name` contained the key name after applying `symbolic_name()`, which replaces underscores with spaces. Instead of replacing the underscore in `LAST_PRINTABLE` with a space, I moved the check above the call to `symbolic_name()`. This is more readable and future-proof in my opinion. --- kitty/key_encoding.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kitty/key_encoding.py b/kitty/key_encoding.py index 60aeaa467..a3618145b 100644 --- a/kitty/key_encoding.py +++ b/kitty/key_encoding.py @@ -296,11 +296,11 @@ def update_encoding(): key_map = {} i = len(ans) for k in sorted(keys, key=lambda k: getattr(defines, k)): + if k in ('GLFW_KEY_LAST', 'GLFW_KEY_LAST_PRINTABLE'): + continue val = getattr(defines, k) name = symbolic_name(k) - if val <= defines.GLFW_KEY_LAST and name not in ( - 'LAST', 'LAST_PRINTABLE' - ) and val != defines.GLFW_KEY_UNKNOWN: + if val <= defines.GLFW_KEY_LAST and val != defines.GLFW_KEY_UNKNOWN: if name not in ans: ans[name] = encode(i) i += 1