From 5d0c96872bc3aeed7405ab7bee668b8e77ec7430 Mon Sep 17 00:00:00 2001 From: Wanten <41904684+WantenMN@users.noreply.github.com> Date: Wed, 4 Jun 2025 17:14:01 +0800 Subject: [PATCH] editor: Stabilize IME candidate box position during pre-edit on Wayland (#28429) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modify the `replace_and_mark_text_in_range` method in the `Editor` to keep the cursor at the start of the preedit range during IME composition. Previously, the cursor would move to the end of the preedit text with each update, causing the IME candidate box to shift (e.g., when typing pinyin with Fcitx5 on Wayland). This change ensures the cursor and candidate box remain fixed until the composition is committed, improving the IME experience. Closes #21004 Release Notes: - N/A --------- Co-authored-by: Mikayla Maki Co-authored-by: 张小白 <364772080@qq.com> --- crates/gpui/src/platform/linux/wayland/window.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/gpui/src/platform/linux/wayland/window.rs b/crates/gpui/src/platform/linux/wayland/window.rs index bb0b29df442a6e550f7a0411d955de3e21dd635d..3fb8a588fb9f4de498b636b283007846c6328109 100644 --- a/crates/gpui/src/platform/linux/wayland/window.rs +++ b/crates/gpui/src/platform/linux/wayland/window.rs @@ -635,12 +635,8 @@ impl WaylandWindowStatePtr { let mut bounds: Option> = None; if let Some(mut input_handler) = state.input_handler.take() { drop(state); - if let Some(selection) = input_handler.selected_text_range(true) { - bounds = input_handler.bounds_for_range(if selection.reversed { - selection.range.start..selection.range.start - } else { - selection.range.end..selection.range.end - }); + if let Some(selection) = input_handler.marked_text_range() { + bounds = input_handler.bounds_for_range(selection.start..selection.start); } self.state.borrow_mut().input_handler = Some(input_handler); }