git: Adjust rendering of git hunks (#25824)

- Light themes get their own values (creating better contrast and a
better distinction between staged and unstaged hunks in light themes.)
- Scrollbar git hunks indicators now use the correct colors

Before:

![CleanShot 2025-02-28 at 14 31
29@2x](https://github.com/user-attachments/assets/038fe11c-7163-4f1b-92b8-56b24c8e9443)

After:

![CleanShot 2025-02-28 at 14 32
04@2x](https://github.com/user-attachments/assets/869d33d9-d925-4cbe-84bd-e54caf971431)


Release Notes:

- Fixed an issue where git hunk indicators in editor scrollbars used the
incorrect colors.
This commit is contained in:
Nate Butler 2025-02-28 14:54:12 -05:00 committed by GitHub
parent fad4df5e70
commit 8a22a07d14
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4344,6 +4344,8 @@ impl EditorElement {
} }
fn paint_diff_hunks(layout: &mut EditorLayout, window: &mut Window, cx: &mut App) { fn paint_diff_hunks(layout: &mut EditorLayout, window: &mut Window, cx: &mut App) {
let is_light = cx.theme().appearance().is_light();
if layout.display_hunks.is_empty() { if layout.display_hunks.is_empty() {
return; return;
} }
@ -4408,7 +4410,7 @@ impl EditorElement {
hunk_to_paint hunk_to_paint
{ {
let background_color = if secondary_status != DiffHunkSecondaryStatus::None { let background_color = if secondary_status != DiffHunkSecondaryStatus::None {
background_color.opacity(0.3) background_color.opacity(if is_light { 0.2 } else { 0.32 })
} else { } else {
background_color.opacity(1.0) background_color.opacity(1.0)
}; };
@ -5102,9 +5104,15 @@ impl EditorElement {
end_display_row.0 -= 1; end_display_row.0 -= 1;
} }
let color = match &hunk.status().kind { let color = match &hunk.status().kind {
DiffHunkStatusKind::Added => theme.status().created, DiffHunkStatusKind::Added => {
DiffHunkStatusKind::Modified => theme.status().modified, theme.colors().version_control_added
DiffHunkStatusKind::Deleted => theme.status().deleted, }
DiffHunkStatusKind::Modified => {
theme.colors().version_control_modified
}
DiffHunkStatusKind::Deleted => {
theme.colors().version_control_deleted
}
}; };
ColoredRange { ColoredRange {
start: start_display_row, start: start_display_row,
@ -6700,12 +6708,14 @@ impl Element for EditorElement {
.editor .editor
.update(cx, |editor, cx| editor.highlighted_display_rows(window, cx)); .update(cx, |editor, cx| editor.highlighted_display_rows(window, cx));
let is_light = cx.theme().appearance().is_light();
for (ix, row_info) in row_infos.iter().enumerate() { for (ix, row_info) in row_infos.iter().enumerate() {
let Some(diff_status) = row_info.diff_status else { let Some(diff_status) = row_info.diff_status else {
continue; continue;
}; };
let staged_opacity = 0.10; let staged_opacity = if is_light { 0.14 } else { 0.10 };
let unstaged_opacity = 0.04; let unstaged_opacity = 0.04;
let background_color = match diff_status.kind { let background_color = match diff_status.kind {