Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/components/FileEditToolDiff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ export function FileEditToolDiff(props: Props): React.ReactNode {
function DiffBody({ promise, file_path }: { promise: Promise<DiffData>; file_path: string }): React.ReactNode {
const { patch, firstLine, fileContent } = use(promise);
const { columns } = useTerminalSize();

if (patch.length === 0) {
return (
<DiffFrame>
<Text dimColor>No changes to display</Text>
</DiffFrame>
);
}

return (
<DiffFrame>
<StructuredDiffList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function FileWriteToolDiff({ file_path, content, fileExists, oldContent }
borderRight={false}
paddingX={paddingX}
>
{hunks ? (
{hunks && hunks.length > 0 ? (
intersperse(
hunks.map(_ => (
<StructuredDiff
Expand Down
3 changes: 3 additions & 0 deletions src/utils/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ export function getPatchForDisplay({
convertLeadingTabsToSpaces(new_string),
)

if (escapedOldString === '') {
return escapedNewString
}
if (replace_all) {
return p.replaceAll(escapedOldString, () => escapedNewString)
} else {
Expand Down