From c71791d64e9e53cfcbc7f79ae3889629501b78da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B0=8F=E7=99=BD?= <364772080@qq.com> Date: Thu, 5 Jun 2025 20:13:09 +0800 Subject: [PATCH] windows: Fix Japanese IME (#32153) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed an issue where pressing `Escape` wouldn’t clear all pre-edit text when using Japanese IME. Release Notes: - N/A --- crates/gpui/src/platform/windows/events.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index dba88fba4cedb23063e9370ffe8ef6cd75e6823d..8c69bc9df7e054a092598fe3d7694b19fcbb909a 100644 --- a/crates/gpui/src/platform/windows/events.rs +++ b/crates/gpui/src/platform/windows/events.rs @@ -679,6 +679,14 @@ fn handle_ime_composition_inner( lparam: LPARAM, state_ptr: Rc, ) -> Option { + if lparam.0 == 0 { + // Japanese IME may send this message with lparam = 0, which indicates that + // there is no composition string. + with_input_handler(&state_ptr, |input_handler| { + input_handler.replace_text_in_range(None, ""); + })?; + return Some(0); + } let mut ime_input = None; if lparam.0 as u32 & GCS_COMPSTR.0 > 0 { let comp_string = parse_ime_compostion_string(ctx)?;