@@ -18,28 +18,29 @@ import { buildStyledBlock, type CharStyle } from "./ansiString";
1818 */
1919export const DiffSplitLineNumberArea : React . FC < {
2020 lineNumber ?: number ;
21- width : number ;
21+ lineNumWidth : number ;
2222 height : number ;
2323 backgroundColor : string ;
2424 color : string ;
2525 dim ?: boolean ;
26- } > = React . memo ( ( { lineNumber, width , height, backgroundColor, color, dim = false } ) => {
27- // Total width: leftPad + num + rightPad = 1 + width + 1
28- const totalWidth = width + 2 ;
26+ } > = React . memo ( ( { lineNumber, lineNumWidth , height, backgroundColor, color, dim = false } ) => {
27+ // Total width: leftPad + num + rightPad = 1 + lineNumWidth + 1
28+ const totalWidth = lineNumWidth + 2 ;
2929
3030 const content = React . useMemo ( ( ) => {
3131 const style : CharStyle = { backgroundColor, color, dim } ;
3232 const lines : string [ ] = [ ] ;
3333
3434 for ( let row = 0 ; row < height ; row ++ ) {
3535 // Left padding + line number (right-aligned) + right padding
36- const numPart = row === 0 && lineNumber !== undefined ? lineNumber . toString ( ) . padStart ( width ) : " " . repeat ( width ) ;
36+ const numPart =
37+ row === 0 && lineNumber !== undefined ? lineNumber . toString ( ) . padStart ( lineNumWidth ) : " " . repeat ( lineNumWidth ) ;
3738 const lineText = ` ${ numPart } ` ;
3839 lines . push ( buildStyledBlock ( lineText , totalWidth , 1 , style , "left" ) ) ;
3940 }
4041
4142 return lines . join ( "\n" ) ;
42- } , [ lineNumber , width , height , backgroundColor , color , dim , totalWidth ] ) ;
43+ } , [ lineNumber , lineNumWidth , height , backgroundColor , color , dim , totalWidth ] ) ;
4344
4445 return (
4546 < Box width = { totalWidth } flexShrink = { 0 } >
@@ -57,14 +58,14 @@ DiffSplitLineNumberArea.displayName = "DiffSplitLineNumberArea";
5758export const DiffUnifiedLineNumberArea : React . FC < {
5859 oldLineNumber ?: number ;
5960 newLineNumber ?: number ;
60- width : number ;
61+ lineNumWidth : number ;
6162 height : number ;
6263 backgroundColor : string ;
6364 color : string ;
6465 dim ?: boolean ;
65- } > = React . memo ( ( { oldLineNumber, newLineNumber, width , height, backgroundColor, color, dim = false } ) => {
66- // Total width: oldNum + separator + newNum + separator = width + 1 + width + 1
67- const totalWidth = width * 2 + 2 ;
66+ } > = React . memo ( ( { oldLineNumber, newLineNumber, lineNumWidth , height, backgroundColor, color, dim = false } ) => {
67+ // Total width: oldNum + separator + newNum + separator = lineNumWidth + 1 + lineNumWidth + 1
68+ const totalWidth = lineNumWidth * 2 + 3 ;
6869
6970 const content = React . useMemo ( ( ) => {
7071 const style : CharStyle = { backgroundColor, color, dim } ;
@@ -73,15 +74,19 @@ export const DiffUnifiedLineNumberArea: React.FC<{
7374 for ( let row = 0 ; row < height ; row ++ ) {
7475 // Old number (right-aligned) + separator + new number (right-aligned) + separator
7576 const oldPart =
76- row === 0 && oldLineNumber !== undefined ? oldLineNumber . toString ( ) . padStart ( width ) : " " . repeat ( width ) ;
77+ row === 0 && oldLineNumber !== undefined
78+ ? oldLineNumber . toString ( ) . padStart ( lineNumWidth )
79+ : " " . repeat ( lineNumWidth ) ;
7780 const newPart =
78- row === 0 && newLineNumber !== undefined ? newLineNumber . toString ( ) . padStart ( width ) : " " . repeat ( width ) ;
79- const lineText = `${ oldPart } ${ newPart } ` ;
81+ row === 0 && newLineNumber !== undefined
82+ ? newLineNumber . toString ( ) . padStart ( lineNumWidth )
83+ : " " . repeat ( lineNumWidth ) ;
84+ const lineText = ` ${ oldPart } ${ newPart } ` ;
8085 lines . push ( buildStyledBlock ( lineText , totalWidth , 1 , style , "left" ) ) ;
8186 }
8287
8388 return lines . join ( "\n" ) ;
84- } , [ oldLineNumber , newLineNumber , width , height , backgroundColor , color , dim , totalWidth ] ) ;
89+ } , [ oldLineNumber , newLineNumber , lineNumWidth , height , backgroundColor , color , dim , totalWidth ] ) ;
8590
8691 return (
8792 < Box width = { totalWidth } flexShrink = { 0 } >
0 commit comments