enhance: truncate but show long lines in diffs (#39279)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Sergio Benitez
2026-09-12 13:56:25 +02:00
committed by GitHub
parent da37b7916b
commit 1e13badb39
13 changed files with 430 additions and 222 deletions
+2 -2
View File
@@ -4,12 +4,12 @@
package gitdiff
import (
"bufio"
"bytes"
"fmt"
"html/template"
"io"
"gitea.dev/modules/git"
"gitea.dev/modules/setting"
"github.com/alecthomas/chroma/v2"
@@ -29,7 +29,7 @@ type BlobExcerptOptions struct {
func (diffSection *DiffSection) fillExcerptLines(reader io.Reader, leftStart, rightStart, chunkSize int) error {
buf := &bytes.Buffer{}
scanner := bufio.NewScanner(reader)
scanner := git.NewGitDiffScanner(reader)
var diffLines []*DiffLine
for rightLineIdx := 1; rightLineIdx < rightStart+chunkSize; rightLineIdx++ {
if ok := scanner.Scan(); !ok {