@@ -1191,7 +1191,7 @@ func GetDiffForRender(ctx context.Context, repoLink string, gitRepo *git.Reposit
11911191 return nil , err
11921192 }
11931193
1194- checker , err := attribute .NewBatchChecker (gitRepo , opts .AfterCommitID , []string {attribute .LinguistVendored , attribute .LinguistGenerated , attribute .LinguistLanguage , attribute .GitlabLanguage })
1194+ checker , err := attribute .NewBatchChecker (gitRepo , opts .AfterCommitID , []string {attribute .LinguistVendored , attribute .LinguistGenerated , attribute .LinguistLanguage , attribute .GitlabLanguage , attribute . Diff })
11951195 if err != nil {
11961196 return nil , err
11971197 }
@@ -1200,13 +1200,15 @@ func GetDiffForRender(ctx context.Context, repoLink string, gitRepo *git.Reposit
12001200 for _ , diffFile := range diff .Files {
12011201 isVendored := optional .None [bool ]()
12021202 isGenerated := optional .None [bool ]()
1203+ attrDiff := optional .None [string ]()
12031204 attrs , err := checker .CheckPath (diffFile .Name )
12041205 if err == nil {
12051206 isVendored , isGenerated = attrs .GetVendored (), attrs .GetGenerated ()
12061207 language := attrs .GetLanguage ()
12071208 if language .Has () {
12081209 diffFile .Language = language .Value ()
12091210 }
1211+ attrDiff = attrs .Get (attribute .Diff ).ToString ()
12101212 }
12111213
12121214 // Populate Submodule URLs
@@ -1228,7 +1230,8 @@ func GetDiffForRender(ctx context.Context, repoLink string, gitRepo *git.Reposit
12281230 diffFile .Sections = append (diffFile .Sections , tailSection )
12291231 }
12301232
1231- if ! setting .Git .DisableDiffHighlight {
1233+ shouldFullFileHighlight := ! setting .Git .DisableDiffHighlight && attrDiff .Value () == ""
1234+ if shouldFullFileHighlight {
12321235 if limitedContent .LeftContent != nil && limitedContent .LeftContent .buf .Len () < MaxDiffHighlightEntireFileSize {
12331236 diffFile .highlightedLeftLines = highlightCodeLines (diffFile , true /* left */ , limitedContent .LeftContent .buf .String ())
12341237 }
0 commit comments