fix diffview for search-and-replace tool and insert tool

This commit is contained in:
sam hoang
2025-01-28 22:13:51 +07:00
parent eef34c03dc
commit 003bb5cabc

View File

@@ -1573,11 +1573,7 @@ export class Cline {
await delay(200)
}
const diff = formatResponse.createPrettyPatch(
relPath,
this.diffViewProvider.originalContent,
updatedContent,
)
const diff = formatResponse.createPrettyPatch(relPath, fileContent, updatedContent)
if (!diff) {
pushToolResult(`No changes needed for '${relPath}'`)
@@ -1707,6 +1703,8 @@ export class Cline {
// Read the original file content
const fileContent = await fs.readFile(absolutePath, "utf-8")
this.diffViewProvider.editType = "modify"
this.diffViewProvider.originalContent = fileContent
let lines = fileContent.split("\n")
for (const op of parsedOperations) {
@@ -1745,11 +1743,7 @@ export class Cline {
this.consecutiveMistakeCount = 0
// Show diff preview
const diff = formatResponse.createPrettyPatch(
relPath,
this.diffViewProvider.originalContent,
newContent,
)
const diff = formatResponse.createPrettyPatch(relPath, fileContent, newContent)
if (!diff) {
pushToolResult(`No changes needed for '${relPath}'`)