ce99e7ef26e1226d678c2c7e91e6a6e1099e8659
Closes #45046 The root of the issue is anchor resolution. When we apply adjacent edits, they get merged into a single edit. In the scenario described in the issue, this is what happens: 1. We create an anchor at the end of each selection (bias::right) on the snapshot before the edits. 2. We collect the edits and apply them to the buffer. 3. Since the edits are adjacent (>=), the buffer merges them into a single edit. 4. As a result, we apply one edit to the text buffer, creating a single visible fragment with length = 3. 5. The buffer ends up with fragments like: [F(len = 3, visible = true), F(len = 1, visible = false), ...] 6. After the edits, we resolve the previously created anchors to produce zero-width selections (cursors). 7. All anchors resolve into deleted fragments, so their resolved offset equals the cumulative visible offset, which is 3. 8. We now have 3 cursors with identical coordinates (0;3). 9. These cursors get merged into a single cursor. I tried several approaches, but they either felt wrong or didn’t work. In particular, I tried adjusting anchor resolution using the delta stored in handle_input, but this doesn’t help because selections are merged immediately after anchor resolution. The only workable solution I found is to avoid anchors entirely for the adjacent-edit case. Instead, we can compute the final cursor positions directly from the edits and create the selections based on that information. Release Notes: - Fixed an issue where adjacent selection insert would merge cursors --------- Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Co-authored-by: Lukas Wirth <me@lukaswirth.dev>
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 issue)
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
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.
Languages
Rust
94.9%
JSON-with-Comments
2.7%
Python
0.8%
Inno Setup
0.3%
Tree-sitter Query
0.3%
Other
0.5%