Fix 'cannot read split of undefined' error

This commit is contained in:
Saoud Rizwan
2024-07-20 16:17:43 -04:00
parent 01205ed622
commit aa310366ad

View File

@@ -316,14 +316,15 @@ export class ClaudeDev {
const completeDiffStringConverted = completeDiffStringRaw const completeDiffStringConverted = completeDiffStringRaw
.map((part, index) => { .map((part, index) => {
const prefix = part.added ? "+ " : part.removed ? "- " : " " const prefix = part.added ? "+ " : part.removed ? "- " : " "
return (part.value ?? []) const value = part.value || ""
return value
.split("\n") .split("\n")
.map((line, lineIndex) => { .map((line, lineIndex) => {
// avoid adding an extra empty line at the very end of the diff output // avoid adding an extra empty line at the very end of the diff output
if ( if (
line === "" && line === "" &&
index === completeDiffStringRaw.length - 1 && index === completeDiffStringRaw.length - 1 &&
lineIndex === (part.value ?? []).split("\n").length - 1 lineIndex === value.split("\n").length - 1
) { ) {
return null return null
} }