Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Merge branch 'main' into git-project-panel-and-scrollbar-styling

Mikayla Maki9a47415cb5bb
diff --cc crates/editor/src/element.rs
index 502975c144f,13a24bfc2c1..ba9adfdd16b
--- a/crates/editor/src/element.rs
+++ b/crates/editor/src/element.rs
@@@ -1052,51 -1052,53 +1052,54 @@@ impl EditorElement
..Default::default()
});
- let diff_style = &theme::current(cx).editor.scrollbar.git;
- for hunk in layout
- .position_map
- .snapshot
- .buffer_snapshot
- .git_diff_hunks_in_range(0..(max_row.floor() as u32))
- {
- let start_display = Point::new(hunk.buffer_range.start, 0)
- .to_display_point(&layout.position_map.snapshot.display_snapshot);
- let end_display = Point::new(hunk.buffer_range.end, 0)
- .to_display_point(&layout.position_map.snapshot.display_snapshot);
- let start_y = y_for_row(start_display.row() as f32);
- let mut end_y = if hunk.buffer_range.start == hunk.buffer_range.end {
- y_for_row((end_display.row() + 1) as f32)
- } else {
- y_for_row((end_display.row()) as f32)
- };
+
- if end_y - start_y < 1. {
- end_y = start_y + 1.;
- }
- let bounds = RectF::from_points(vec2f(left, start_y), vec2f(right, end_y));
-
- let color = match hunk.status() {
- DiffHunkStatus::Added => diff_style.inserted,
- DiffHunkStatus::Modified => diff_style.modified,
- DiffHunkStatus::Removed => diff_style.deleted,
- };
-
- let border = Border {
- width: 1.,
- color: style.thumb.border.color,
- overlay: false,
- top: false,
- right: true,
- bottom: false,
- left: true,
- };
+ if layout.is_singleton && settings::get::<EditorSettings>(cx).scrollbar.git_diff {
+ let diff_style = theme::current(cx).editor.diff.clone();
+ for hunk in layout
+ .position_map
+ .snapshot
+ .buffer_snapshot
+ .git_diff_hunks_in_range(0..(max_row.floor() as u32))
+ {
+ let start_display = Point::new(hunk.buffer_range.start, 0)
+ .to_display_point(&layout.position_map.snapshot.display_snapshot);
+ let end_display = Point::new(hunk.buffer_range.end, 0)
+ .to_display_point(&layout.position_map.snapshot.display_snapshot);
+ let start_y = y_for_row(start_display.row() as f32);
+ let mut end_y = if hunk.buffer_range.start == hunk.buffer_range.end {
+ y_for_row((end_display.row() + 1) as f32)
+ } else {
+ y_for_row((end_display.row()) as f32)
+ };
- scene.push_quad(Quad {
- bounds,
- background: Some(color),
- border,
- corner_radius: style.thumb.corner_radius,
- })
+ if end_y - start_y < 1. {
+ end_y = start_y + 1.;
+ }
+ let bounds = RectF::from_points(vec2f(left, start_y), vec2f(right, end_y));
+
+ let color = match hunk.status() {
+ DiffHunkStatus::Added => diff_style.inserted,
+ DiffHunkStatus::Modified => diff_style.modified,
+ DiffHunkStatus::Removed => diff_style.deleted,
+ };
+
+ let border = Border {
+ width: 1.,
+ color: style.thumb.border.color,
+ overlay: false,
+ top: false,
+ right: true,
+ bottom: false,
+ left: true,
+ };
+
+ scene.push_quad(Quad {
+ bounds,
+ background: Some(color),
+ border,
+ corner_radius: style.thumb.corner_radius,
+ })
+ }
}
scene.push_quad(Quad {