From 4cc63e9919486581f7acc49829ebf21bc52dd871 Mon Sep 17 00:00:00 2001
From: KN4CK3R <admin@oldschoolhack.me>
Date: Thu, 24 Jun 2021 17:47:46 +0200
Subject: Fix diff expansion is missing final line in a file (#16222)

* Fixed down offset.

* Fixed wrong line count result.
---
 routers/web/repo/compare.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'routers/web/repo')

diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go
index f53a31769d..fddfc4a63a 100644
--- a/routers/web/repo/compare.go
+++ b/routers/web/repo/compare.go
@@ -714,7 +714,11 @@ func ExcerptBlob(ctx *context.Context) {
 		lastLeft += chunkSize
 		lastRight += chunkSize
 	} else {
-		section.Lines, err = getExcerptLines(commit, filePath, lastLeft, lastRight, idxRight-lastRight-1)
+		offset := -1
+		if direction == "down" {
+			offset = 0
+		}
+		section.Lines, err = getExcerptLines(commit, filePath, lastLeft, lastRight, idxRight-lastRight+offset)
 		leftHunkSize = 0
 		rightHunkSize = 0
 		idxLeft = lastLeft
-- 
cgit v1.2.3