mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
On showing diff/file, use the tab_width specified on .editorconfig, if any (#3241)
Closes #3182
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
|
||||
"golang.org/x/net/html/charset"
|
||||
"golang.org/x/text/transform"
|
||||
"gopkg.in/editorconfig/editorconfig-core-go.v1"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
@@ -109,6 +110,15 @@ func NewFuncMap() []template.FuncMap {
|
||||
mimeType := mime.TypeByExtension(filepath.Ext(filename))
|
||||
return strings.HasPrefix(mimeType, "image/")
|
||||
},
|
||||
"TabSizeClass": func(ec *editorconfig.Editorconfig, filename string) string {
|
||||
if ec != nil {
|
||||
def := ec.GetDefinitionForFilename(filename)
|
||||
if def.TabWidth > 0 {
|
||||
return fmt.Sprintf("tab-size-%d", def.TabWidth)
|
||||
}
|
||||
}
|
||||
return "tab-size-8"
|
||||
},
|
||||
}}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user