## 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 in
24f7bb6e27, but later reverted it in
8cfe7a2a54441f89c170fbdd165a49b3e787b3c4 because 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
Zed
Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Installation
On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).
Other platforms are not yet available:
- Web (tracking discussion)
Developing Zed
Contributing
See CONTRIBUTING.md for ways you can contribute to Zed.
Also... we're hiring! Check out our jobs page for open roles.
Licensing
Zed source code is licensed primarily under GPL-3.0-or-later, with Apache-2.0 components where marked.
License information for third party dependencies must be correctly provided for CI to pass.
We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:
- Is it showing a
no license specifiederror for a crate you've created? If so, addpublish = falseunder[package]in your crate's Cargo.toml. - Is the error
failed to satisfy license requirementsfor a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to theacceptedarray inscript/licenses/zed-licenses.toml. - Is
cargo-aboutunable to find the license for a dependency? If so, add a clarification field at the end ofscript/licenses/zed-licenses.toml, as specified in the cargo-about book.
Sponsorship
Zed is developed by Zed Industries, Inc., a for-profit company.
If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.