Fix detection that a diff hunk is expanded (#18302)

Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
Max Brunsfeld
2024-09-24 17:39:44 -04:00
committed by GitHub
co-authored by Marshall
parent 5045f984a9
commit da1ef13442
3 changed files with 12 additions and 7 deletions
+1 -4
View File
@@ -2214,10 +2214,7 @@ struct Row10;"#};
let snapshot = editor.snapshot(cx);
let all_hunks = editor_hunks(editor, &snapshot, cx);
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
assert_eq!(
expanded_hunks_background_highlights(editor, cx),
vec![DisplayRow(5)..=DisplayRow(5)]
);
assert_eq!(expanded_hunks_background_highlights(editor, cx), Vec::new());
assert_eq!(
all_hunks,
vec![(
+5 -1
View File
@@ -1335,7 +1335,11 @@ impl EditorElement {
}
match status {
DiffHunkStatus::Added => {}
DiffHunkStatus::Modified => {}
DiffHunkStatus::Modified => {
if is_expanded {
*status = DiffHunkStatus::Added;
}
}
DiffHunkStatus::Removed => {
if is_expanded {
return None;
+6 -2
View File
@@ -279,8 +279,12 @@ impl Editor {
..Point::new(remaining_hunk.row_range.end.0, 0);
hunks_to_expand.push(HoveredHunk {
status: hunk_status(&remaining_hunk),
multi_buffer_range: remaining_hunk_point_range
.to_anchors(&snapshot.buffer_snapshot),
multi_buffer_range: snapshot
.buffer_snapshot
.anchor_before(remaining_hunk_point_range.start)
..snapshot
.buffer_snapshot
.anchor_after(remaining_hunk_point_range.end),
diff_base_byte_range: remaining_hunk.diff_base_byte_range.clone(),
});
}