forked from forgejo/forgejo
On showing diff/file, use the tab_width specified on .editorconfig, if any (#3241)
Closes #3182
This commit is contained in:
parent
aa1fc30b89
commit
dbed39ba05
9 changed files with 137 additions and 2 deletions
|
@ -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"
|
||||
},
|
||||
}}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue