Skip to content

Commit 2dfcfe0

Browse files
committed
respect editorconfig server-side too
1 parent c071ad5 commit 2dfcfe0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

modules/util/string.go

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package util
55

66
import (
77
"strings"
8+
89
"github.com/yuin/goldmark/util"
910
)
1011

routers/web/repo/editor.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,21 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
277277
operation = "create"
278278
}
279279

280+
eol := setting.UI.EditorEol
281+
editorconfigEol := ""
282+
ec, _, err := ctx.Repo.GetEditorconfig()
283+
if err == nil {
284+
def, err := ec.GetDefinitionForFilename(form.TreePath)
285+
if err == nil {
286+
editorconfigEol = strings.ToUpper(def.EndOfLine)
287+
if editorconfigEol != "" {
288+
eol = editorconfigEol
289+
}
290+
}
291+
}
292+
280293
content := form.Content
281-
if setting.UI.EditorEol == "CRLF" {
294+
if eol == "CRLF" {
282295
content = util.ConvertToCRLF(content)
283296
} else {
284297
content = util.ConvertToLF(content)

0 commit comments

Comments
 (0)