mirror of
https://github.com/zed-industries/zed.git
synced 2026-05-27 00:08:42 +00:00
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> |
||
|---|---|---|
| .. | ||
| src | ||
| Cargo.toml | ||
| LICENSE-GPL | ||