## Summary Fixes #66688. When splitting, the RHS display map has a weak reference to the LHS display map. If the RHS editor outlives the `SplittableEditor`, the LHS display map will be deallocated. However, the scroll anchor may still refer to it. This leads to a panic in `ScrollManager::native_anchor` at line `scroll.rs:242`. This PR ensures that the same clean-up as in `unsplit` occurs when the `SplittableEditor` is released. The first commit refactors this clean-up into a function that takes a `&mut App`. The second commit adds this function to an `on_release` handler. We choose to do clean-up on release rather than adding fallback logic in `native_anchor`, as it removes the stale state in its source. Fallback logic can be added if desired. ## Testing - Added test case `test_rhs_editor_outlives_released_split`. This scrolls within the LHS, releases the split editor, ensures that the RHS editor lives longer, and attempts to get the native anchor. Before this change, this test panics with the error given in the issue. After this change, the test passes. - All tests pass in `cargo test -p editor` (1235). - No clippy warnings in `./script/clippy -p editor`. - Manually tested on macOS. ### How to test Within a window: 1. Have two projects open in the sidebar. 2. In one project, with uncommitted changes, run `git: diff`, then open in split mode with `editor: toggle split diff`. 3. Scroll in the left pane. 4. Move the project into a new window with `workspace: move project to new window` (or "Open Project in New Window" from the project's menu in the sidebar). 5. Change the theme with `theme selector: toggle`. On main, Zed will panic here. With this change, no problem occurs. ## Self-review - [x] Checked diff for quality, security, reliability and performance. - [ ] UI change checklist followed (if any) https://zed.dev/docs/development/ui-checklist. (N/A, no UI changes) - [x] Test(s) added to cover new/changed behaviour. Release Notes: - Fixed a panic when moving a project with a split diff to a new window. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
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.