优化agent请求文件修改权限时的文件差异显示样式

This commit is contained in:
xintaofei
2026-03-28 18:10:20 +08:00
parent 622d8c90bd
commit a049db51e2
3 changed files with 45 additions and 36 deletions

View File

@@ -145,7 +145,15 @@ function buildCompactDiffFromTexts(
Math.min(oldLines.length, oldLines.length - suffix + contextLines)
)
const parts: string[] = [`--- ${path}`, `+++ ${path}`]
const oldStart = Math.max(1, prefix - before.length + 1)
const oldCount = before.length + removed.length + after.length
const newCount = before.length + added.length + after.length
const parts: string[] = [
`--- ${path}`,
`+++ ${path}`,
`@@ -${oldStart},${oldCount} +${oldStart},${newCount} @@`,
]
for (const line of before) parts.push(` ${line}`)
for (const line of removed) parts.push(`-${line}`)
for (const line of added) parts.push(`+${line}`)