# editor: Expand excerpts from deleted diff hunks \(\#63946\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/c6124d3525ce84ebd99ba65ba0d8adcf2acfe195)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: c6124d3525ce84ebd99ba65ba0d8adcf2acfe195

Requested commit: c6124d3525ce84ebd99ba65ba0d8adcf2acfe195

Commit: c6124d3525ce84ebd99ba65ba0d8adcf2acfe195

Tree: 98864f98c885303123603447c3b1cdd32bb77a45

Author: Ibrahim Khan

Committer: GitHub

## Message

```
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>
```

## Parents

- [59adbbe8b96dfff4ee9ce25e18681f8189904f70](https://git.cafe/gitcafe/zed/commit/59adbbe8b96dfff4ee9ce25e18681f8189904f70?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/c6124d3525ce84ebd99ba65ba0d8adcf2acfe195?format=markdown)
