Fix stale hunks after commit (#24663)
Fixes a regression introduced in #24475. Release Notes: - N/A
This commit is contained in:
parent
bbea3a2184
commit
6e7416eb00
2 changed files with 9 additions and 14 deletions
|
@ -587,18 +587,16 @@ impl BufferDiff {
|
|||
range: Range<Anchor>,
|
||||
buffer: &text::BufferSnapshot,
|
||||
cx: &App,
|
||||
) -> Option<Range<Anchor>> {
|
||||
) -> Range<Anchor> {
|
||||
let start = self
|
||||
.hunks_intersecting_range(range.clone(), &buffer, cx)
|
||||
.next()?
|
||||
.buffer_range
|
||||
.start;
|
||||
.next()
|
||||
.map_or(Anchor::MIN, |hunk| hunk.buffer_range.start);
|
||||
let end = self
|
||||
.hunks_intersecting_range_rev(range.clone(), &buffer)
|
||||
.next()?
|
||||
.buffer_range
|
||||
.end;
|
||||
Some(start..end)
|
||||
.next()
|
||||
.map_or(Anchor::MAX, |hunk| hunk.buffer_range.end);
|
||||
start..end
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
|
|
@ -260,15 +260,12 @@ impl BufferDiffState {
|
|||
let changed_range = match (unstaged_changed_range, uncommitted_changed_range) {
|
||||
(None, None) => None,
|
||||
(Some(unstaged_range), None) => {
|
||||
uncommitted_diff.range_to_hunk_range(unstaged_range, &buffer, cx)
|
||||
Some(uncommitted_diff.range_to_hunk_range(unstaged_range, &buffer, cx))
|
||||
}
|
||||
(None, Some(uncommitted_range)) => Some(uncommitted_range),
|
||||
(Some(unstaged_range), Some(uncommitted_range)) => maybe!({
|
||||
let expanded_range = uncommitted_diff.range_to_hunk_range(
|
||||
unstaged_range,
|
||||
&buffer,
|
||||
cx,
|
||||
)?;
|
||||
let expanded_range =
|
||||
uncommitted_diff.range_to_hunk_range(unstaged_range, &buffer, cx);
|
||||
let start = expanded_range.start.min(&uncommitted_range.start, &buffer);
|
||||
let end = expanded_range.end.max(&uncommitted_range.end, &buffer);
|
||||
Some(start..end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue