@@ -1239,7 +1239,7 @@ func GetDiffForRender(ctx context.Context, repoLink string, gitRepo *git.Reposit
1239
1239
return nil , err
1240
1240
}
1241
1241
1242
- checker , err := attribute .NewBatchChecker (gitRepo , opts .AfterCommitID , []string {attribute .LinguistVendored , attribute .LinguistGenerated , attribute .LinguistLanguage , attribute .GitlabLanguage })
1242
+ checker , err := attribute .NewBatchChecker (gitRepo , opts .AfterCommitID , []string {attribute .LinguistVendored , attribute .LinguistGenerated , attribute .LinguistLanguage , attribute .GitlabLanguage , attribute . Diff })
1243
1243
if err != nil {
1244
1244
return nil , err
1245
1245
}
@@ -1248,13 +1248,15 @@ func GetDiffForRender(ctx context.Context, repoLink string, gitRepo *git.Reposit
1248
1248
for _ , diffFile := range diff .Files {
1249
1249
isVendored := optional .None [bool ]()
1250
1250
isGenerated := optional .None [bool ]()
1251
+ attrDiff := optional .None [string ]()
1251
1252
attrs , err := checker .CheckPath (diffFile .Name )
1252
1253
if err == nil {
1253
1254
isVendored , isGenerated = attrs .GetVendored (), attrs .GetGenerated ()
1254
1255
language := attrs .GetLanguage ()
1255
1256
if language .Has () {
1256
1257
diffFile .Language = language .Value ()
1257
1258
}
1259
+ attrDiff = attrs .Get (attribute .Diff ).ToString ()
1258
1260
}
1259
1261
1260
1262
// Populate Submodule URLs
@@ -1276,7 +1278,8 @@ func GetDiffForRender(ctx context.Context, repoLink string, gitRepo *git.Reposit
1276
1278
diffFile .Sections = append (diffFile .Sections , tailSection )
1277
1279
}
1278
1280
1279
- if ! setting .Git .DisableDiffHighlight {
1281
+ shouldFullFileHighlight := ! setting .Git .DisableDiffHighlight && attrDiff .Value () == ""
1282
+ if shouldFullFileHighlight {
1280
1283
if limitedContent .LeftContent != nil && limitedContent .LeftContent .buf .Len () < MaxDiffHighlightEntireFileSize {
1281
1284
diffFile .highlightedLeftLines = highlightCodeLines (diffFile , true /* left */ , limitedContent .LeftContent .buf .String ())
1282
1285
}
0 commit comments