From 4e2a08edb798c9eac49daff72f808881854d33ea Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 20 Jun 2024 10:39:10 -0700 Subject: [PATCH] Fix missing IME keys when no input handler is set (#13325) This fixes a bug introduced by https://github.com/zed-industries/zed/pull/12702, where GPUI would only generate the correct key events if you had an input handler set. Release Notes: - N/A --- crates/gpui/src/platform/mac/window.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index ac1ec027ba..4b2cd7144e 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -310,7 +310,7 @@ unsafe fn build_window_class(name: &'static str, superclass: &Class) -> *const C } #[allow(clippy::enum_variant_names)] -#[derive(Clone)] +#[derive(Clone, Debug)] enum ImeInput { InsertText(String, Option>), SetMarkedText(String, Option>, Option>), @@ -1911,7 +1911,7 @@ fn send_to_input_handler(window: &Object, ime: ImeInput) { let mut lock = window_state.lock(); if let Some(mut input_handler) = lock.input_handler.take() { - match ime.clone() { + match ime { ImeInput::InsertText(text, range) => { if let Some(ime_input) = lock.last_ime_inputs.as_mut() { ime_input.push((text, range)); @@ -1931,6 +1931,15 @@ fn send_to_input_handler(window: &Object, ime: ImeInput) { } } window_state.lock().input_handler = Some(input_handler); + } else { + match ime { + ImeInput::InsertText(text, range) => { + if let Some(ime_input) = lock.last_ime_inputs.as_mut() { + ime_input.push((text, range)); + } + } + _ => {} + } } } }