-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add ui.EDITOR_EOL, default to saving files with LF again #28119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
04bb2a5
d39adbb
ab1e9ca
586b8d3
c071ad5
2dfcfe0
2fdf6d9
e02ccd7
6aaee67
c321a68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,6 +149,9 @@ func NewFuncMap() template.FuncMap { | |
"MermaidMaxSourceCharacters": func() int { | ||
return setting.MermaidMaxSourceCharacters | ||
}, | ||
"EditorEol": func() string { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
return setting.UI.EditorEol | ||
}, | ||
|
||
// ----------------------------------------------------------------- | ||
// render | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,7 +3,11 @@ | |||||
|
||||||
package util | ||||||
|
||||||
import "github.com/yuin/goldmark/util" | ||||||
import ( | ||||||
"strings" | ||||||
|
||||||
"github.com/yuin/goldmark/util" | ||||||
) | ||||||
|
||||||
func isSnakeCaseUpper(c byte) bool { | ||||||
return 'A' <= c && c <= 'Z' | ||||||
|
@@ -85,3 +89,13 @@ func ToSnakeCase(input string) string { | |||||
} | ||||||
return util.BytesToReadOnlyString(res) | ||||||
} | ||||||
|
||||||
// convert all newlines in string to \n | ||||||
func ToLF(str string) string { | ||||||
return strings.ReplaceAll(str, "\r", "") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
// convert all newlines in string to \r\n | ||||||
func ToCRLF(str string) string { | ||||||
return strings.ReplaceAll(ToLF(str), "\n", "\r\n") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -45,3 +45,11 @@ func TestToSnakeCase(t *testing.T) { | |||||
assert.Equal(t, expected, ToSnakeCase(input)) | ||||||
} | ||||||
} | ||||||
|
||||||
func TestToLF(t *testing.T) { | ||||||
assert.Equal(t, "\na\nbc\n\n", ToLF("\r\na\r\nb\rc\n\n")) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or how do we want to handle this case? |
||||||
} | ||||||
|
||||||
func TestToCRLF(t *testing.T) { | ||||||
assert.Equal(t, "\r\na\r\nbc\r\n\r\n", ToCRLF("\r\na\r\nb\rc\n\n")) | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this
ini
tag here is unnecessary because thiscase conversation is done implicitely, but I do like this expliciteness so that the name stays greppable.By the way, where does this case conversation happen? It's not from the ini package, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the correct Go name would even be
EditorEOL