From decc9624b71c619f2b65ef0e854a274dcbf49ef2 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 10 Jul 2025 21:56:32 -0700 Subject: [PATCH] Fix git diff hunk 0 based start line --- services/gitdiff/gitdiff.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index 9964329876..adfb44c72e 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -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 {