diff --git a/models/git_diff.go b/models/git_diff.go index 9796ef59f..ab70139fb 100644 --- a/models/git_diff.go +++ b/models/git_diff.go @@ -161,7 +161,6 @@ type DiffFile struct { IsBin bool IsRenamed bool Sections []*DiffSection - HighlightClass string } func (diffFile *DiffFile) GetType() int { @@ -169,10 +168,7 @@ func (diffFile *DiffFile) GetType() int { } func (diffFile *DiffFile) GetHighlightClass() string { - if diffFile.HighlightClass == "" { - diffFile.HighlightClass = highlight.FileNameToHighlightClass(diffFile.Name) - } - return diffFile.HighlightClass + return highlight.FileNameToHighlightClass(diffFile.Name) } type Diff struct { diff --git a/templates/repo/diff_box.tmpl b/templates/repo/diff_box.tmpl index f96ebda52..455f07002 100644 --- a/templates/repo/diff_box.tmpl +++ b/templates/repo/diff_box.tmpl @@ -34,6 +34,7 @@ {{range $i, $file := .Diff.Files}} + {{$highlightClass := $file.GetHighlightClass}}

@@ -76,13 +77,13 @@ {{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}} -
{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}
+
{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}
{{if $line.RightIdx}}{{$line.RightIdx}}{{end}} -
{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}
+
{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}
{{end}} @@ -104,7 +105,7 @@ {{end}} -
{{$section.GetComputedInlineDiffFor $line}}
+
{{$section.GetComputedInlineDiffFor $line}}
{{end}}