-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
crystal tool format
on Windows converts all CRLF
line endings to LF
#13772
Comments
I don't think it's a bug, it's a problem with tool configuration. |
How can I configure crystal tool format not to automatically convert crysatal-lang/crystal uses .gitattributes, but I don't think it is directly related to this issue. |
I mean, maybe the configuration of git and editor should be modified. Even on Windows, there's nothing wrong with using |
That is correct. (I also set |
This behaviour is indeed intentional. See #5831 (comment) and other comments in that issue. The purpose of the formatter is to transform Crystal source code into a standardized format that ideally everyone can live with. When working with git the recommended setting is |
I am by no means a CRLF enthusiast, and I agree with the policy of recommending the use of LF for practical purposes. The newline codes used by the formatter are listed here, and it seems easy enough to change it to use CRLF. crystal/src/compiler/crystal/tools/formatter.cr Lines 4926 to 4927 in 63e2342
--- a/src/compiler/crystal/tools/formatter.cr
+++ b/src/compiler/crystal/tools/formatter.cr
@@ -4923,8 +4923,8 @@ module Crystal
line.rstrip
end
end
- result = lines.join('\n') + '\n'
- result = "" if result == "\n"
+ result = lines.join("\r\n") + "\r\n"
+ result = "" if result == "\r\n"
if @shebang
result = result[0] + result[2..-1]
end (I'm not sure how to compile crystals on Windows, though. ) |
There's always the option to use the formatter or not. (Or your could use it and then convert newlines afterwards explicitly 🤷) The formatter is supposed to be basic and a bit opinionated. It won't make it right for everyone. But it's intended to be acceptable by most. Could you explain why you think it's important to use CRLF, what's your use case? |
Closing due to no activity. We can reopen if there are more substantial arguments. |
This is usually a good thing for Linux and macOS systems, but it might not work well on Windows. This can be especially problematic if you're using Git
core.autocrlf
.The text was updated successfully, but these errors were encountered: