editor: Expand excerpts from deleted diff hunks (#63946)
# Objective
Fixes #62278.
Allow `editor: expand excerpts` from deleted text in unified diffs.
## Solution
- Resolve cursor and selection ranges against the current snapshot,
including deleted hunks.
- Preserve half-open selection boundaries and include trailing empty
excerpts at EOF.
- Skip removed paths during expansion.
## Testing
Regression coverage includes deleted-hunk cursors and selections, stale
paths, selections ending at excerpt boundaries, and trailing empty
excerpts. The boundary and EOF cases cover all three expansion
directions. The Bookmarks action case uses `excerpt_context_lines: 0`.
The new boundary and EOF regressions failed before the fix and passed
afterward.
- `cargo test --locked -p editor -p multi_buffer --lib`: 1026 editor
tests and 67 multibuffer tests passed; 1 ignored.
- `./script/clippy -p editor -p multi_buffer`: passed.
- `cargo fmt --all -- --check`: passed.
- `git diff --check origin/main..HEAD`: passed.
Automated testing ran on Linux. The first full run hit a SQLite table
lock in `persistence::tests::test_save_and_get_serialized_editor`. The
isolated test and full rerun passed.
## Self-Review Checklist:
- [x] I have reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks, if any, have justifying comments
- [x] The content adheres to Zed UI standards
- [x] Tests cover the new behavior
- [x] Performance impact has been considered and is acceptable
Release Notes:
- Fixed excerpt expansion when the selection is on deleted text in
unified diffs
---------
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
c6124d3525Ibrahim Khan committed on 9/16/2026, 4:04:24 PM· committed by GitHubparent59adbbe