fix: prevent split on undefined(#491) (#563)

This commit is contained in:
xiguatoutou
2026-03-24 01:14:15 +08:00
committed by GitHub
parent 42a131389a
commit b54cdf8168

View File

@@ -33,7 +33,12 @@ export const ToolDiffViewer: React.FC<ToolDiffViewerProps> = ({
: 'bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400';
const diffLines = useMemo(
() => createDiff(oldContent, newContent),
() => {
if (oldContent === undefined || newContent === undefined) {
return [];
}
return createDiff(oldContent, newContent)
},
[createDiff, oldContent, newContent]
);