File tree Expand file tree Collapse file tree 2 files changed +3
-24
lines changed Expand file tree Collapse file tree 2 files changed +3
-24
lines changed Original file line number Diff line number Diff line change @@ -176,24 +176,6 @@ function computeDiffStats(diff?: string): { added: number; removed: number } | n
176176 return null
177177}
178178
179- /**
180- * Converts new file content to unified diff format (all lines as additions)
181- */
182- function convertNewFileToUnifiedDiff ( content : string , filePath ?: string ) : string {
183- const fileName = filePath || "file"
184- const lines = content . split ( "\n" )
185-
186- let diff = `--- /dev/null\n`
187- diff += `+++ ${ fileName } \n`
188- diff += `@@ -0,0 +1,${ lines . length } @@\n`
189-
190- for ( const line of lines ) {
191- diff += `+${ line } \n`
192- }
193-
194- return diff
195- }
196-
197179export const ChatRowContent = ( {
198180 message,
199181 lastModifiedMessage,
@@ -639,7 +621,7 @@ export const ChatRowContent = ({
639621 < div className = "pl-6" >
640622 < CodeAccordian
641623 path = { tool . path }
642- code = { convertNewFileToUnifiedDiff ( tool . content || "" , tool . path ) }
624+ code = { cleanDiffContent ?? "" }
643625 language = "diff"
644626 isLoading = { message . partial }
645627 isExpanded = { isExpanded }
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ export function extractUnifiedDiff(params: {
4040/** Detects unified diff by presence of headers/hunks */
4141function isUnifiedDiff ( s : string ) : boolean {
4242 const hasHunk = / ( ^ | \n ) @ @ \s + - [ 0 - 9 , ] + \s + \+ [ 0 - 9 , ] + \s + @ @ / . test ( s )
43- const hasHeaders = / ( ^ | \n ) - - - \s | \n \+ \+ \+ \s / . test ( s )
43+ const hasHeaders = / ( ^ | \n ) - - - \s | ( ^ | \n ) \+ \+ \+ \s / . test ( s )
4444 return hasHunk || hasHeaders
4545}
4646
@@ -55,12 +55,9 @@ function isSearchReplace(s: string): boolean {
5555function stripCData ( s : string ) : string {
5656 return (
5757 s
58- // Remove HTML-encoded and raw CDATA open
58+ // Remove HTML-encoded and raw CDATA open/close (case-insensitive covers both)
5959 . replace ( / < ! \[ C D A T A \[ / gi, "" )
60- . replace ( / < ! \[ C D A T A \[ / g, "" )
61- // Remove HTML-encoded and raw CDATA close
6260 . replace ( / \] \] > / gi, "" )
63- . replace ( / \] \] > / g, "" )
6461 )
6562}
6663
You can’t perform that action at this time.
0 commit comments