From 7c1405db379487f00e6e4eee9735e79f5a24b279 Mon Sep 17 00:00:00 2001 From: Jakub Charvat Date: Sat, 15 Mar 2025 00:49:53 +0100 Subject: [PATCH] Update rendering of gutter diff hunks to show whether a hunk is staged or not (#26809) In the gutter, it seems more intuitive to me for the unstaged hunks to be hollow, indicating an action left to complete, and the staged hunks to be filled. I therefore flipped the style of expanded hunks to match the gutter icons. Is that acceptable? And would it be a breaking change? If it is not acceptable, then 058dc216d5a284033eebd38d28853f69aa336a55 contains the opposite behaviour, it is not a problem to revert to it. In the following images, the first hunk is always ~unstaged~ staged and the second is ~staged~ unstaged. image image
image image Release Notes: - Improved gutter diff hunks to show whether a hunk is staged --- crates/editor/src/element.rs | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 812cf3c14373cfa781187d90849c53146a1e219d..3095f77862da6dbdc8a0c1e98439da953801597f 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -4376,7 +4376,9 @@ impl EditorElement { }), }; - if let Some((hunk_bounds, background_color, corner_radii, _)) = hunk_to_paint { + if let Some((hunk_bounds, background_color, corner_radii, status)) = hunk_to_paint { + let unstaged = status.has_secondary_hunk(); + // Flatten the background color with the editor color to prevent // elements below transparent hunks from showing through let flattened_background_color = cx @@ -4385,13 +4387,29 @@ impl EditorElement { .editor_background .blend(background_color); - window.paint_quad(quad( - hunk_bounds, - corner_radii, - flattened_background_color, - Edges::default(), - transparent_black(), - )); + if unstaged { + window.paint_quad(quad( + hunk_bounds, + corner_radii, + flattened_background_color, + Edges::default(), + transparent_black(), + )); + } else { + let flattened_unstaged_background_color = cx + .theme() + .colors() + .editor_background + .blend(background_color.opacity(0.3)); + + window.paint_quad(quad( + hunk_bounds, + corner_radii, + flattened_unstaged_background_color, + Edges::all(Pixels(1.0)), + flattened_background_color, + )); + } } } });