@@ -1239,7 +1239,7 @@ func GetDiffForRender(ctx context.Context, repoLink string, gitRepo *git.Reposit
12391239 return nil , err
12401240 }
12411241
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 })
12431243 if err != nil {
12441244 return nil , err
12451245 }
@@ -1248,13 +1248,15 @@ func GetDiffForRender(ctx context.Context, repoLink string, gitRepo *git.Reposit
12481248 for _ , diffFile := range diff .Files {
12491249 isVendored := optional .None [bool ]()
12501250 isGenerated := optional .None [bool ]()
1251+ attrDiff := optional .None [string ]()
12511252 attrs , err := checker .CheckPath (diffFile .Name )
12521253 if err == nil {
12531254 isVendored , isGenerated = attrs .GetVendored (), attrs .GetGenerated ()
12541255 language := attrs .GetLanguage ()
12551256 if language .Has () {
12561257 diffFile .Language = language .Value ()
12571258 }
1259+ attrDiff = attrs .Get (attribute .Diff ).ToString ()
12581260 }
12591261
12601262 // Populate Submodule URLs
@@ -1276,7 +1278,8 @@ func GetDiffForRender(ctx context.Context, repoLink string, gitRepo *git.Reposit
12761278 diffFile .Sections = append (diffFile .Sections , tailSection )
12771279 }
12781280
1279- if ! setting .Git .DisableDiffHighlight {
1281+ shouldFullFileHighlight := ! setting .Git .DisableDiffHighlight && attrDiff .Value () == ""
1282+ if shouldFullFileHighlight {
12801283 if limitedContent .LeftContent != nil && limitedContent .LeftContent .buf .Len () < MaxDiffHighlightEntireFileSize {
12811284 diffFile .highlightedLeftLines = highlightCodeLines (diffFile , true /* left */ , limitedContent .LeftContent .buf .String ())
12821285 }
0 commit comments