From 946f4a312aa592c4fe4995c5b3f543b7523d2ea0 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Thu, 22 Feb 2024 12:48:15 -0500 Subject: [PATCH] Wayland: avoid replacing text with empty string (#8103) Fix an issue where the `ime_key` is sometimes an empty string, and pressing a keystroke replaces the selected text. E.g. select some text, press `Escape`: selected text is deleted. --- crates/gpui/src/platform/linux/util.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/platform/linux/util.rs b/crates/gpui/src/platform/linux/util.rs index 6791ffee36fd188cb92a9e444b9766474afbb0a3..d0ee6287c9f92e4867a16ef078cd3a01a6105699 100644 --- a/crates/gpui/src/platform/linux/util.rs +++ b/crates/gpui/src/platform/linux/util.rs @@ -17,7 +17,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)).then_some(key_utf8); + let ime_key = ((key_utf32 == 0 || (key_utf32 >= 32 && key_utf32 != 127)) + && !key_utf8.is_empty()) + .then_some(key_utf8); Keystroke { modifiers,