zed/crates/buffer_diff
Cole Miller 930d9321dc
git: Fix panic when unstaged diff is recalculated before its primary diff (#49753)
For inverted diff APIs like `hunks_intersecting_base_text_range`, we
need a snapshot of the main buffer to use as context to compare hunk
anchors, convert anchors to points, etc. Previously, we were always
using a snapshot of the main buffer at the time when the diff was
calculated. This worked well for the hunks of the primary `BufferDiff`,
but it's not valid when the diff also has a secondary set of hunks,
because those hunks are recalculated on their own schedule--so it's
possible for the hunks of the secondary diff to contain anchors that are
newer than the original buffer snapshot that was taken at the time the
primary diff hunks were last calculated. This caused a panic when using
these anchors with the original buffer snapshot.

This PR fixes the issue by using the same approach for inverted diffs as
for non-inverted diffs at the multibuffer level: we take a snapshot of
the main buffer at the time when we snapshot the diff state (including
the diff itself), guaranteeing that that snapshot will be new enough to
resolve all the anchors included in both the primary diff and the
secondary diff.

Closes ZED-54J

Release Notes:

- Fixed a panic that could occur when using the branch diff in split
view mode.

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
2026-02-20 17:11:30 -05:00
..
src git: Fix panic when unstaged diff is recalculated before its primary diff (#49753) 2026-02-20 17:11:30 -05:00
Cargo.toml ztracing: Enable memory profiling and callstack sampling (#47052) 2026-01-17 19:29:19 +00:00
LICENSE-GPL