Fix a couple of diff hunk issues (#24913)

- Fix hunks losing their expandedness when staged or unstaged
- Disable collapsing hunks in the project diff editor

Release Notes:

- N/A

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Cole Miller
2025-02-15 18:18:32 +00:00
committed by GitHub
co-authored by Conrad Irwin
parent 56f13ddc50
commit 394bb8f4e6
3 changed files with 32 additions and 28 deletions
-22
View File
@@ -13193,28 +13193,6 @@ async fn test_diff_base_change_with_expanded_diff_hunks(
cx.set_diff_base("new diff base!");
executor.run_until_parked();
cx.assert_state_with_diff(
r#"
use some::mod2;
const A: u32 = 42;
const C: u32 = 42;
fn main(ˇ) {
//println!("hello");
println!("world");
//
//
}
"#
.unindent(),
);
cx.update_editor(|editor, window, cx| {
editor.expand_all_diff_hunks(&ExpandAllHunkDiffs, window, cx);
});
executor.run_until_parked();
cx.assert_state_with_diff(
r#"
- new diff base!
+11 -3
View File
@@ -4829,7 +4829,15 @@ impl EditorElement {
) {
for (_, hunk_hitbox) in &layout.display_hunks {
if let Some(hunk_hitbox) = hunk_hitbox {
window.set_cursor_style(CursorStyle::PointingHand, hunk_hitbox);
if !self
.editor
.read(cx)
.buffer()
.read(cx)
.all_diff_hunks_expanded()
{
window.set_cursor_style(CursorStyle::PointingHand, hunk_hitbox);
}
}
}
@@ -5717,7 +5725,7 @@ impl EditorElement {
window.on_mouse_event({
let position_map = layout.position_map.clone();
let editor = self.editor.clone();
let multi_buffer_range =
let diff_hunk_range =
layout
.display_hunks
.iter()
@@ -5753,7 +5761,7 @@ impl EditorElement {
Self::mouse_left_down(
editor,
event,
multi_buffer_range.clone(),
diff_hunk_range.clone(),
&position_map,
line_numbers.as_ref(),
window,