Fix cursor position when navigating to a multibuffer's first excerpt (#25723)

This PR fixes an unexpected cursor position when jumping to the
beginning of the project diff editor's first excerpt if that excerpt
starts with a deleted region. Previously, the cursor would end up in the
*following* region in this situation; now it ends up at the start of the
deleted region, as happens already for excerpts that are not the first.

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
This commit is contained in:
Cole Miller 2025-02-27 14:53:34 -05:00 committed by GitHub
parent 91862ddc9f
commit 7ec3702b47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 182 additions and 5 deletions

View file

@ -4535,7 +4535,6 @@ impl MultiBufferSnapshot {
base_text_byte_range,
..
}) => {
let mut in_deleted_hunk = false;
if let Some(diff_base_anchor) = &anchor.diff_base_anchor {
if let Some(base_text) =
self.diffs.get(buffer_id).and_then(|diff| diff.base_text())
@ -4550,7 +4549,6 @@ impl MultiBufferSnapshot {
base_text_byte_range.start..base_text_offset,
);
position.add_assign(&position_in_hunk);
in_deleted_hunk = true;
} else if at_transform_end {
diff_transforms.next(&());
continue;
@ -4558,9 +4556,6 @@ impl MultiBufferSnapshot {
}
}
}
if !in_deleted_hunk {
position = diff_transforms.end(&()).1 .0;
}
}
_ => {
if at_transform_end && anchor.diff_base_anchor.is_some() {