forked from forgejo/forgejo
Enable sintax highlighting on diff view. Close #733
This commit is contained in:
parent
137a49e834
commit
2bfb8bb5fd
9 changed files with 38 additions and 11 deletions
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/process"
|
||||
"github.com/gogits/gogs/modules/template/highlight"
|
||||
)
|
||||
|
||||
type DiffLineType uint8
|
||||
|
@ -160,12 +161,20 @@ type DiffFile struct {
|
|||
IsBin bool
|
||||
IsRenamed bool
|
||||
Sections []*DiffSection
|
||||
HighlightClass string
|
||||
}
|
||||
|
||||
func (diffFile *DiffFile) GetType() int {
|
||||
return int(diffFile.Type)
|
||||
}
|
||||
|
||||
func (diffFile *DiffFile) GetHighlightClass() string {
|
||||
if diffFile.HighlightClass == "" {
|
||||
diffFile.HighlightClass = highlight.FileNameToHighlightClass(diffFile.Name)
|
||||
}
|
||||
return diffFile.HighlightClass
|
||||
}
|
||||
|
||||
type Diff struct {
|
||||
TotalAddition, TotalDeletion int
|
||||
Files []*DiffFile
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue