Touch up stale hunks fix (#24669)

Release Notes:

- N/A

Co-authored-by: Max <max@zed.dev>
This commit is contained in:
Cole Miller 2025-02-11 12:47:41 -05:00 committed by GitHub
parent 7c00eec08b
commit 759ea0ec48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 13 deletions

View file

@ -587,16 +587,18 @@ impl BufferDiff {
range: Range<Anchor>,
buffer: &text::BufferSnapshot,
cx: &App,
) -> Range<Anchor> {
) -> Option<Range<Anchor>> {
let start = self
.hunks_intersecting_range(range.clone(), &buffer, cx)
.next()
.map_or(Anchor::MIN, |hunk| hunk.buffer_range.start);
.next()?
.buffer_range
.start;
let end = self
.hunks_intersecting_range_rev(range.clone(), &buffer)
.next()
.map_or(Anchor::MAX, |hunk| hunk.buffer_range.end);
start..end
.next()?
.buffer_range
.end;
Some(start..end)
}
#[allow(clippy::too_many_arguments)]