From 58f57491b1825cdc73d7ac8020b3026f61fca11a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B0=8F=E7=99=BD?= <364772080@qq.com> Date: Tue, 16 Apr 2024 03:08:38 +0800 Subject: [PATCH] windows: Remove `last_ime_input` (#10506) It seems that windows always report IME composition string, so there is no need to store this string manually. Release Notes: - N/A --- crates/gpui/src/platform/windows/window.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/gpui/src/platform/windows/window.rs b/crates/gpui/src/platform/windows/window.rs index 3d9657c119979b0ac4efd49a65cc22d47a99fa6a..5885a74b1582ca63fffb3d0a5eb291d6b7b079db 100644 --- a/crates/gpui/src/platform/windows/window.rs +++ b/crates/gpui/src/platform/windows/window.rs @@ -52,7 +52,6 @@ pub(crate) struct WindowsWindowInner { pub(crate) handle: AnyWindowHandle, hide_title_bar: bool, display: RefCell>, - last_ime_input: RefCell>, click_state: RefCell, fullscreen: Cell>, } @@ -114,7 +113,6 @@ impl WindowsWindowInner { let renderer = RefCell::new(BladeRenderer::new(gpu, extent)); let callbacks = RefCell::new(Callbacks::default()); let display = RefCell::new(display); - let last_ime_input = RefCell::new(None); let click_state = RefCell::new(ClickState::new()); let fullscreen = Cell::new(None); Self { @@ -129,7 +127,6 @@ impl WindowsWindowInner { handle, hide_title_bar, display, - last_ime_input, click_state, fullscreen, } @@ -816,6 +813,7 @@ impl WindowsWindowInner { } fn handle_ime_composition(&self, lparam: LPARAM) -> Option { + let mut ime_input = None; if lparam.0 as u32 & GCS_COMPSTR.0 > 0 { let Some((string, string_len)) = self.parse_ime_compostion_string() else { return None; @@ -829,10 +827,10 @@ impl WindowsWindowInner { Some(0..string_len), ); self.input_handler.set(Some(input_handler)); - *self.last_ime_input.borrow_mut() = Some(string); + ime_input = Some(string); } if lparam.0 as u32 & GCS_CURSORPOS.0 > 0 { - let Some(ref comp_string) = *self.last_ime_input.borrow() else { + let Some(ref comp_string) = ime_input else { return None; }; let caret_pos = self.retrieve_composition_cursor_position(); @@ -863,7 +861,6 @@ impl WindowsWindowInner { }; input_handler.replace_text_in_range(None, &ime_char); self.input_handler.set(Some(input_handler)); - *self.last_ime_input.borrow_mut() = None; self.invalidate_client_area(); Some(0) }