mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Enable sintax highlighting on diff view. Close #733
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user