Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

windows: Properly handle dead char (#30629)

张小白7aabbb04262f
diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs
index fad7a557605..cdf7140a9a2 100644
--- a/crates/gpui/src/platform/windows/events.rs
+++ b/crates/gpui/src/platform/windows/events.rs
@@ -89,6 +89,7 @@ pub(crate) fn handle_msg(
WM_KEYDOWN => handle_keydown_msg(wparam, lparam, state_ptr),
WM_KEYUP => handle_keyup_msg(wparam, state_ptr),
WM_CHAR => handle_char_msg(wparam, lparam, state_ptr),
+ WM_DEADCHAR => handle_dead_char_msg(wparam, state_ptr),
WM_IME_STARTCOMPOSITION => handle_ime_position(handle, state_ptr),
WM_IME_COMPOSITION => handle_ime_composition(handle, lparam, state_ptr),
WM_SETCURSOR => handle_set_cursor(lparam, state_ptr),
@@ -512,6 +513,14 @@ fn handle_char_msg(
Some(0)
}
+fn handle_dead_char_msg(wparam: WPARAM, state_ptr: Rc<WindowsWindowStatePtr>) -> Option<isize> {
+ let ch = char::from_u32(wparam.0 as u32)?.to_string();
+ with_input_handler(&state_ptr, |input_handler| {
+ input_handler.replace_and_mark_text_in_range(None, &ch, None);
+ });
+ None
+}
+
fn handle_mouse_down_msg(
handle: HWND,
button: MouseButton,