From caadc58bead6cb654d7e1da25faaba72be79cd27 Mon Sep 17 00:00:00 2001 From: apricotbucket28 Date: Mon, 6 May 2024 16:26:19 -0300 Subject: [PATCH] linux: Don't set ime_key for non-ASCII characters doing e. g. CTRL + 2 would set ime_key to "\0", which would make the text system crash while trying to render it. --- crates/gpui/src/platform/linux/platform.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/gpui/src/platform/linux/platform.rs b/crates/gpui/src/platform/linux/platform.rs index 696421714b..289f7eafa7 100644 --- a/crates/gpui/src/platform/linux/platform.rs +++ b/crates/gpui/src/platform/linux/platform.rs @@ -616,11 +616,9 @@ impl Keystroke { } }; - // Ignore control characters (and DEL) for the purposes of ime_key, - // but if key_utf32 is 0 then assume it isn't one - let ime_key = ((key_utf32 == 0 || (key_utf32 >= 32 && key_utf32 != 127)) - && !key_utf8.is_empty()) - .then_some(key_utf8); + // Ignore control characters (and DEL) for the purposes of ime_key + let ime_key = + (key_utf32 >= 32 && key_utf32 != 127 && !key_utf8.is_empty()).then_some(key_utf8); if handle_consumed_modifiers { let mod_shift_index = state.get_keymap().mod_get_index(xkb::MOD_NAME_SHIFT);