Skip to content
Open
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
4 changes: 3 additions & 1 deletion src/filesystem/__tests__/lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,9 @@ describe('Lib Functions', () => {
];

await expect(applyFileEdits('/test/file.txt', edits, false))
.rejects.toThrow('Could not find exact match for edit');
.rejects.toThrow(
'Use read_file to inspect the exact current content, then retry with oldText copied from the file'
);
});

it('handles complex multi-line edits with indentation', async () => {
Expand Down
6 changes: 5 additions & 1 deletion src/filesystem/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ export async function applyFileEdits(
}

if (!matchFound) {
throw new Error(`Could not find exact match for edit:\n${edit.oldText}`);
throw new Error(
`Could not find exact match for edit:\n${edit.oldText}\n\n` +
`This usually means the requested text differs from the file content in whitespace, indentation, or line endings. ` +
`Use read_file to inspect the exact current content, then retry with oldText copied from the file.`
);
}
}

Expand Down
Loading