From 58e63ffcb760fd8f5ee256d10560cf25969d9b77 Mon Sep 17 00:00:00 2001
From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
Date: Fri, 27 Mar 2026 11:19:36 -0400
Subject: [PATCH] git_graph: Fix checkout curve rendering (#52580)
This makes the curves start later in the graph which is one of the last
things for the graph to be ready for release
### Before
### After
Self-Review Checklist:
- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable
Release Notes:
- N/A or Added/Fixed/Improved ...
---
crates/git_graph/src/git_graph.rs | 80 +++++++++++++++++++------------
1 file changed, 50 insertions(+), 30 deletions(-)
diff --git a/crates/git_graph/src/git_graph.rs b/crates/git_graph/src/git_graph.rs
index 1c2bdae6a193a8dce6e7e9e2d894fabdb9274b8b..305dc8e42d3789cf8495fa30fbb5ca5770b10600 100644
--- a/crates/git_graph/src/git_graph.rs
+++ b/crates/git_graph/src/git_graph.rs
@@ -2192,13 +2192,45 @@ impl GitGraph {
-COMMIT_CIRCLE_RADIUS - COMMIT_CIRCLE_STROKE_WIDTH
};
- let control = match curve_kind {
+ match curve_kind {
CurveKind::Checkout => {
if is_last {
to_column -= column_shift;
}
builder.move_to(point(current_column, current_row));
- point(current_column, to_row)
+
+ if (to_column - current_column).abs() > LANE_WIDTH {
+ // Multi-lane checkout: straight down, small
+ // curve turn, then straight horizontal.
+ if (to_row - current_row).abs() > row_height {
+ let vertical_end =
+ point(current_column, to_row - row_height);
+ builder.line_to(vertical_end);
+ builder.move_to(vertical_end);
+ }
+
+ let lane_shift = if going_right {
+ LANE_WIDTH
+ } else {
+ -LANE_WIDTH
+ };
+ let curve_end =
+ point(current_column + lane_shift, to_row);
+ let curve_control = point(current_column, to_row);
+ builder.curve_to(curve_end, curve_control);
+ builder.move_to(curve_end);
+
+ builder.line_to(point(to_column, to_row));
+ } else {
+ if (to_row - current_row).abs() > row_height {
+ let start_curve =
+ point(current_column, to_row - row_height);
+ builder.line_to(start_curve);
+ builder.move_to(start_curve);
+ }
+ let control = point(current_column, to_row);
+ builder.curve_to(point(to_column, to_row), control);
+ }
}
CurveKind::Merge => {
if is_last {
@@ -2208,37 +2240,25 @@ impl GitGraph {
current_column + column_shift,
current_row - COMMIT_CIRCLE_RADIUS,
));
- point(to_column, current_row)
- }
- };
- match curve_kind {
- CurveKind::Checkout
- if (to_row - current_row).abs() > row_height =>
- {
- let start_curve =
- point(current_column, current_row + row_height);
- builder.line_to(start_curve);
- builder.move_to(start_curve);
- }
- CurveKind::Merge
- if (to_column - current_column).abs() > LANE_WIDTH =>
- {
- let column_shift =
- if going_right { LANE_WIDTH } else { -LANE_WIDTH };
-
- let start_curve = point(
- current_column + column_shift,
- current_row - COMMIT_CIRCLE_RADIUS,
- );
+ if (to_column - current_column).abs() > LANE_WIDTH {
+ let column_shift = if going_right {
+ LANE_WIDTH
+ } else {
+ -LANE_WIDTH
+ };
+ let start_curve = point(
+ current_column + column_shift,
+ current_row - COMMIT_CIRCLE_RADIUS,
+ );
+ builder.line_to(start_curve);
+ builder.move_to(start_curve);
+ }
- builder.line_to(start_curve);
- builder.move_to(start_curve);
+ let control = point(to_column, current_row);
+ builder.curve_to(point(to_column, to_row), control);
}
- _ => {}
- };
-
- builder.curve_to(point(to_column, to_row), control);
+ }
current_row = to_row;
current_column = to_column;
builder.move_to(point(current_column, current_row));