fix(diff): load both blobs of renamed files for diff rendering (#39969) (#39992)

Backport #39969

Co-authored-by: schop-rob <49682405+schop-rob@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
authored and GitHub committed 2026-10-24 14:05:09 +00:00
1 parent 85a85878c7
commit 9d335e8783
2 files changed
+40 -3

No files matched your search

+3 -3
View File
@@ -521,13 +521,13 @@ func (diffFile *DiffFile) prepareDiffRenderDetail(ctx context.Context, gitRepo *
// * for "text" type: need to read up to "highlight limit size" to do full-file-highlighting
contentLimit := util.Iif(diffFile.IsBin, typesniffer.SniffContentSize, MaxFullFileHighlightSizeLimit)
var leftBlobType, rightBlobType typesniffer.SniffedType
if (diffFile.Type == DiffFileDel || diffFile.Type == DiffFileChange) && leftCommit != nil {
if diffFile.Type != DiffFileAdd && leftCommit != nil {
c := getCommitFileBlobAndLimitedContent(ctx, gitRepo, leftCommit, diffFile.OldName, contentLimit)
diffFile.LeftBlob, diffFile.LeftBlobSize, ret.leftLineCount, ret.leftContent = c.gitBlob, c.blobSize, c.lineCount, c.limitedContent
leftBlobType = typesniffer.DetectContentType(ret.leftContent.buf.Bytes())
}
if (diffFile.Type == DiffFileAdd || diffFile.Type == DiffFileChange) && rightCommit != nil {
c := getCommitFileBlobAndLimitedContent(ctx, gitRepo, rightCommit, diffFile.OldName, contentLimit)
if diffFile.Type != DiffFileDel && rightCommit != nil {
c := getCommitFileBlobAndLimitedContent(ctx, gitRepo, rightCommit, diffFile.Name, contentLimit)
diffFile.RightBlob, diffFile.RightBlobSize, ret.rightLineCount, ret.rightContent = c.gitBlob, c.blobSize, c.lineCount, c.limitedContent
rightBlobType = typesniffer.DetectContentType(ret.rightContent.buf.Bytes())
}