0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-17 06:42:52 +02:00

Fix git diff hunk 0 based start line

This commit is contained in:
Lunny Xiao 2025-07-10 21:56:32 -07:00
parent b46623f6a5
commit decc9624b7
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A

View File

@ -864,9 +864,9 @@ func parseHunks(ctx context.Context, curFile *DiffFile, maxLines, maxLineCharact
}
curSection.Lines = append(curSection.Lines, diffLine)
curSection.FileName = curFile.Name
// update line number.
leftLine = lineSectionInfo.LeftIdx
rightLine = lineSectionInfo.RightIdx
// update line number. leftLine and rightLine are 1-based indexes, 0 means 1
leftLine = max(lineSectionInfo.LeftIdx, 1)
rightLine = max(lineSectionInfo.RightIdx, 1)
continue
case '\\':
if maxLines > -1 && curFileLinesCount >= maxLines {