@@ -35,6 +35,9 @@ const THEME_COLOR_LIMIT = 8;
3535 */
3636const REDUX_GEOMETRY_THEMES = new Set ( [ 'redux' , 'redux-dark' , 'redux-color' , 'redux-dark-color' ] ) ;
3737
38+ /** Vertical padding inside the LR branch label rect for redux themes (`drawBranches` `labelPaddingY`). */
39+ const REDUX_BRANCH_LABEL_PADDING_Y = 12 ;
40+
3841/**
3942 * Themes that use per-branch color cycling with a non-default first color
4043 * (avoidDefaultColor logic in calcColorIndex).
@@ -546,11 +549,16 @@ const getCommitPosition = (
546549 isParallelCommits : boolean
547550) : CommitPositionOffset => {
548551 const posWithOffset = dir === 'BT' && isParallelCommits ? pos : pos + LAYOUT_OFFSET ;
549- const y = dir === 'TB' || dir === 'BT' ? posWithOffset : branchPos . get ( commit . branch ) ?. pos ;
552+ const branchY = branchPos . get ( commit . branch ) ?. pos ;
550553 const x = dir === 'TB' || dir === 'BT' ? branchPos . get ( commit . branch ) ?. pos : posWithOffset ;
551- if ( x === undefined || y === undefined ) {
554+ if ( x === undefined || branchY === undefined ) {
552555 throw new Error ( `Position were undefined for commit ${ commit . id } ` ) ;
553556 }
557+ const useReduxGeometry = REDUX_GEOMETRY_THEMES . has ( getConfig ( ) . theme ?? '' ) ;
558+ const y =
559+ dir === 'TB' || dir === 'BT'
560+ ? posWithOffset
561+ : branchY + ( useReduxGeometry ? REDUX_BRANCH_LABEL_PADDING_Y / 2 + 1 : - 2 ) ;
554562 return { x, y, posWithOffset } ;
555563} ;
556564
@@ -878,11 +886,19 @@ const drawBranches = (
878886 if ( pos === undefined ) {
879887 throw new Error ( `Position not found for branch ${ branch . name } ` ) ;
880888 }
889+ // LR spine Y: bkg rect center, dotted line, and commits all sit here.
890+ // TB/BT use pos directly (their line attrs are overridden below).
891+ const spineY =
892+ dir === 'TB' || dir === 'BT'
893+ ? pos
894+ : useReduxGeometry
895+ ? pos + REDUX_BRANCH_LABEL_PADDING_Y / 2 + 1
896+ : pos - 2 ;
881897 const line = g . append ( 'line' ) ;
882898 line . attr ( 'x1' , 0 ) ;
883- line . attr ( 'y1' , pos ) ;
899+ line . attr ( 'y1' , spineY ) ;
884900 line . attr ( 'x2' , maxPos ) ;
885- line . attr ( 'y2' , pos ) ;
901+ line . attr ( 'y2' , spineY ) ;
886902 line . attr ( 'class' , 'branch branch' + adjustIndexForTheme ) ;
887903
888904 if ( dir === 'TB' ) {
@@ -896,7 +912,7 @@ const drawBranches = (
896912 line . attr ( 'y2' , defaultPos ) ;
897913 line . attr ( 'x2' , pos ) ;
898914 }
899- lanes . push ( pos ) ;
915+ lanes . push ( spineY ) ;
900916
901917 const name = branch . name ;
902918
@@ -913,7 +929,7 @@ const drawBranches = (
913929 const bbox = labelElement . getBBox ( ) ;
914930 const borderRadius = useReduxGeometry ? 0 : 4 ;
915931 const labelPaddingX = useReduxGeometry ? 16 : 0 ;
916- const labelPaddingY = useReduxGeometry ? 12 : 0 ;
932+ const labelPaddingY = useReduxGeometry ? REDUX_BRANCH_LABEL_PADDING_Y : 0 ;
917933 if ( look === 'neo' ) {
918934 bkg . attr ( 'data-look' , `neo` ) ;
919935 }
@@ -927,7 +943,7 @@ const drawBranches = (
927943 . attr ( 'rx' , borderRadius )
928944 . attr ( 'ry' , borderRadius )
929945 . attr ( 'x' , - bbox . width - 4 - ( gitGraphConfig . rotateCommitLabel === true ? 30 : 0 ) )
930- . attr ( 'y' , - bbox . height / 2 + 8 )
946+ . attr ( 'y' , - bbox . height / 2 + 10 )
931947 . attr ( 'width' , bbox . width + 18 + labelPaddingX )
932948 . attr ( 'height' , bbox . height + 4 + labelPaddingY ) ;
933949 label . attr (
@@ -938,7 +954,7 @@ const drawBranches = (
938954 ( gitGraphConfig . rotateCommitLabel === true ? 30 : 0 ) +
939955 labelPaddingX / 2 ) +
940956 ', ' +
941- ( pos - bbox . height / 2 - 1 + labelPaddingY / 2 ) +
957+ ( spineY - bbox . height / 2 - 2 ) +
942958 ')'
943959 ) ;
944960 if ( dir === 'TB' ) {
@@ -962,7 +978,7 @@ const drawBranches = (
962978 ) ;
963979 }
964980 } else {
965- bkg . attr ( 'transform' , 'translate(' + - 19 + ' , ' + ( pos - 11 ) + ')' ) ;
981+ bkg . attr ( 'transform' , 'translate(-19, ' + ( spineY - 12 - labelPaddingY / 2 ) + ')' ) ;
966982 }
967983 } ) ;
968984} ;
0 commit comments