editor: Stabilize IME candidate box position during pre-edit on Wayland (#28429)

Wanten , Mikayla Maki , and 张小白 created

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 <mikayla.c.maki@gmail.com>
Co-authored-by: 张小白 <364772080@qq.com>

Change summary

crates/gpui/src/platform/linux/wayland/window.rs | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

Detailed changes

crates/gpui/src/platform/linux/wayland/window.rs 🔗

@@ -635,12 +635,8 @@ impl WaylandWindowStatePtr {
         let mut bounds: Option<Bounds<Pixels>> = 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);
         }