mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Better error messages for diffs
This commit is contained in:
@@ -1237,20 +1237,25 @@ export class Cline {
|
||||
const originalContent = await fs.readFile(absolutePath, "utf-8")
|
||||
|
||||
// Apply the diff to the original content
|
||||
let newContent = this.diffStrategy?.applyDiff(originalContent, diffContent) ?? false
|
||||
if (newContent === false) {
|
||||
const diffResult = this.diffStrategy?.applyDiff(originalContent, diffContent) ?? {
|
||||
success: false,
|
||||
error: "No diff strategy available"
|
||||
}
|
||||
if (!diffResult.success) {
|
||||
this.consecutiveMistakeCount++
|
||||
await this.say("error", `Unable to apply diff to file - contents are out of sync: ${absolutePath}`)
|
||||
pushToolResult(`Error applying diff to file: ${absolutePath} - contents are out of sync. Try re-reading the relevant lines of the file and applying the diff again.`)
|
||||
const errorDetails = diffResult.details ? `\n\nDetails:\n${JSON.stringify(diffResult.details, null, 2)}` : ''
|
||||
await this.say("error", `Unable to apply diff to file: ${absolutePath}\n${diffResult.error}${errorDetails}`)
|
||||
pushToolResult(`Error applying diff to file: ${absolutePath}\n${diffResult.error}${errorDetails}`)
|
||||
break
|
||||
}
|
||||
const newContent = diffResult.content
|
||||
|
||||
this.consecutiveMistakeCount = 0
|
||||
|
||||
// Show diff view before asking for approval
|
||||
this.diffViewProvider.editType = "modify"
|
||||
await this.diffViewProvider.open(relPath);
|
||||
await this.diffViewProvider.update(newContent, true);
|
||||
await this.diffViewProvider.update(diffResult.content, true);
|
||||
await this.diffViewProvider.scrollToFirstDiff();
|
||||
|
||||
const completeMessage = JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user