File tree Expand file tree Collapse file tree 6 files changed +26
-16
lines changed
Expand file tree Collapse file tree 6 files changed +26
-16
lines changed Original file line number Diff line number Diff line change @@ -56,18 +56,21 @@ const InternalDiffSplitLine = ({
5656
5757 // Calculate row heights - must match the actual wrap width used in DiffContent
5858 // DiffContent receives contentWidth and wraps at (contentWidth - 2) for the operator column and end padding
59- let oldRow = getCurrentLineRow ( { content : oldLine ?. value || "" , width : contentWidth - 2 } ) ;
60- let newRow = getCurrentLineRow ( { content : newLine ?. value || "" , width : contentWidth - 2 } ) ;
59+ const noNewlineText = "\\ No newline at end of file" ;
6160
62- oldRow =
61+ // Include "No newline" text in row calculation if present
62+ const oldContent =
6363 oldLine ?. diff ?. changes ?. hasLineChange && oldLine ?. diff ?. changes . newLineSymbol === NewLineSymbol . NEWLINE
64- ? oldRow + 1
65- : oldRow ;
64+ ? ( oldLine ?. value || "" ) + noNewlineText
65+ : oldLine ?. value || "" ;
6666
67- newRow =
67+ const newContent =
6868 newLine ?. diff ?. changes ?. hasLineChange && newLine ?. diff ?. changes . newLineSymbol === NewLineSymbol . NEWLINE
69- ? newRow + 1
70- : newRow ;
69+ ? ( newLine ?. value || "" ) + noNewlineText
70+ : newLine ?. value || "" ;
71+
72+ const oldRow = getCurrentLineRow ( { content : oldContent , width : contentWidth - 2 } ) ;
73+ const newRow = getCurrentLineRow ( { content : newContent , width : contentWidth - 2 } ) ;
7174
7275 const row = Math . max ( oldRow , newRow ) ;
7376
Original file line number Diff line number Diff line change @@ -181,10 +181,15 @@ const InternalDiffUnifiedLine = ({
181181
182182 const contentWidth = columns - ( lineNumWidth + 1 ) * 2 - 1 ;
183183
184- // Use contentWidth - 2 to match the actual wrap width in DiffContent (operator column takes 1 char, end padding takes 1 char)
185- let row = getCurrentLineRow ( { content : rawLine , width : contentWidth - 2 } ) ;
184+ // Include "No newline" text in row calculation if present
185+ const noNewlineText = "\\ No newline at end of file" ;
186+ const contentWithSymbol =
187+ diffLine ?. changes ?. hasLineChange && diffLine . changes . newLineSymbol === NewLineSymbol . NEWLINE
188+ ? rawLine + noNewlineText
189+ : rawLine ;
186190
187- row = diffLine ?. changes ?. hasLineChange && diffLine . changes . newLineSymbol === NewLineSymbol . NEWLINE ? row + 1 : row ;
191+ // Use contentWidth - 2 to match the actual wrap width in DiffContent (operator column takes 1 char, end padding takes 1 char)
192+ const row = getCurrentLineRow ( { content : contentWithSymbol , width : contentWidth - 2 } ) ;
188193
189194 const color = hasDiff
190195 ? theme === "light"
Original file line number Diff line number Diff line change @@ -93,5 +93,6 @@ export const createCodeConfigStore = <T = any>(props: CodeViewProps<T> & { isMou
9393} ;
9494
9595export const getCurrentLineRow = ( { content, width } : { content : string ; width : number } ) => {
96- return Math . ceil ( stringWidth ( content ) / width ) ;
96+ // Ensure minimum of 1 row for empty lines
97+ return Math . max ( 1 , Math . ceil ( stringWidth ( content ) / width ) ) ;
9798} ;
Original file line number Diff line number Diff line change @@ -127,7 +127,8 @@ export const createDiffConfigStore = <T = any>(
127127} ;
128128
129129export const getCurrentLineRow = ( { content, width } : { content : string ; width : number } ) => {
130- return Math . ceil ( stringWidth ( content ) / width ) ;
130+ // Ensure minimum of 1 row for empty lines
131+ return Math . max ( 1 , Math . ceil ( stringWidth ( content ) / width ) ) ;
131132} ;
132133
133134export const getStringContentWithFixedWidth = ( {
Original file line number Diff line number Diff line change @@ -210,11 +210,11 @@ export const highlighterReady = new Promise<DiffHighlighter>((r) => {
210210getDiffViewHighlighter ( ) . then ( ( highlighter ) => {
211211 render (
212212 createElement ( CodeView , {
213- data : { content : temp1 , fileLang : 'ts' } ,
213+ data : { content : temp1 , fileLang : "ts" } ,
214214 // width: 80,
215215 codeViewTheme : "dark" ,
216216 extendData : {
217- newFile : { 107 : { data : "test extend data" } } ,
217+ 107 : { data : "test extend data" } ,
218218 } ,
219219 renderExtendLine : ( { data } ) => {
220220 return createElement (
Original file line number Diff line number Diff line change @@ -422,7 +422,7 @@ getDiffViewHighlighter().then((highlighter) => {
422422 // diffViewTabWidth: 'small',
423423 // diffViewTabSpace: true,
424424 extendData : {
425- newFile : { 107 : { data : "test extend data" } } ,
425+ newFile : { 97 : { data : "test extend data" } } ,
426426 } ,
427427 renderExtendLine : ( { data } ) => {
428428 return createElement (
You can’t perform that action at this time.
0 commit comments