mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-21 08:01:33 +01:00
737f55a1a1
## Summary This PR fixes horizontal jumping of the IME candidate window during text composition. On the shared `selected_bounds` path used by Windows, the candidate window no longer follows the preedit caret character-by-character. Instead, it anchors to the start of the current visual line, which keeps the candidate window stable while typing. Linux Wayland uses a different IME positioning path, so it was not affected by the original implementation in this PR. This PR now also includes a Wayland-specific adjustment so that Wayland uses the same visual-line anchoring behavior. ## Changes 1. **Shared / Windows path** Updated `selected_bounds` in `crates/gpui/src/platform.rs` to use a visual-line-aware anchor for preedit text. This removes the distracting horizontal movement of the candidate window while typing and keeps the anchor aligned with the active visual line. 2. **Linux Wayland path** Updated the Wayland IME area calculation in `crates/gpui_linux/src/linux/wayland/window.rs` to use the same visual-line-start anchoring strategy for preedit text. This brings Linux Wayland in line with the Windows behavior while preserving Wayland's platform-specific IME handling. ## Notes I had previously tried a separate Wayland-specific fix in5d0c96872b, but later reverted it in8cfe7a2a54because the behavior was not good enough and it regressed the original positioning behavior. The current Wayland implementation is a new, simpler approach that keeps the original behavior intact while also removing horizontal candidate-window jumping. ## Visuals ### Windows / shared path * **Before the fix:** (The candidate box moves along with the preedit text, which is distracting) <img width="918" height="675" alt="before" src="https://github.com/user-attachments/assets/29cb05e4-3e99-4b54-9ce3-78710b307ce6" /> <img width="478" height="682" alt="before_1" src="https://github.com/user-attachments/assets/cff38b65-96dd-4ed7-b06b-7fbcd448fab9" /> * **After the fix:** (Candidate box stays fixed at the line start during typing, correctly jumps to new lines or follows active segments) <img width="918" height="675" alt="after" src="https://github.com/user-attachments/assets/4f50a710-dc0d-4959-a313-1184122ab759" /> <img width="478" height="683" alt="after_1" src="https://github.com/user-attachments/assets/8e9df121-ffcc-45ad-ba0b-f1ad3cef87bc" /> ### Linux Wayland * **Before / previous behavior** <img width="552" height="796" alt="before" src="https://github.com/user-attachments/assets/e3e84312-c626-41cb-945f-66c13aa96df6" /> * **After / current implementation** <img width="546" height="772" alt="after" src="https://github.com/user-attachments/assets/a01ab6d7-a3b6-4d56-a1cb-b2b112b6b914" /> --- ## Self-Review Checklist: * [x] I've reviewed my own diff for quality, security, and reliability * [x] Unsafe blocks (if any) have justifying comments * [x] The content is consistent with the UI/UX checklist * [x] Tests cover the new/changed behavior (manual verification only) * [x] Performance impact has been considered and is acceptable Release Notes: - N/A