Skip to content
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

Line endings appear to not be converted when they occur in multiline comments (?) #665

Closed
Duckwhale opened this issue Mar 30, 2023 · 2 comments · Fixed by #666
Closed

Line endings appear to not be converted when they occur in multiline comments (?) #665

Duckwhale opened this issue Mar 30, 2023 · 2 comments · Fixed by #666
Labels
bug Something isn't working

Comments

@Duckwhale
Copy link

Heyo, we've run into an odd formatting glitch that causes huge git diffs in combination with VS Code's LF/CRLF setting.

In this example file, we have CRLFs present in the comment but LFs everywhere else (as created by StyLua, using the default config):

image

Copy these hex bytes for a simple test case (CRLF/LF distinction):

0D 0A 2D 2D 5B 5B 0D 0A 20 20 20 20 20 20 74 65 73 74 0D 0A 20 20 20 20 20 20 2D 2D 20 61 73 64 66 0D 0A 20 20 5D 5D 0D 0A

After running StyLua on this CRLF-based file, all CRLFs in the regular code are correctly turned into LF, but those in the comment are not:

image

Again, the hex bytes show that this is the case:

0A 2D 2D 5B 5B 0D 0A 20 20 20 20 20 20 74 65 73 74 0D 0A 20 20 20 20 20 20 2D 2D 20 61 73 64 66 0D 0A 20 20 5D 5D 0A

I would expect all line endings to be consistent after running the formatter, which is is preferable to ugly hacks like autocrlf:

image

Expected hex bytes:

0A 2D 2D 5B 5B 0A 20 20 20 20 20 20 74 65 73 74 0A 20 20 20 20 20 20 2D 2D 20 61 73 64 66 0A 20 20 5D 5D 0A

I don't know Rust at all so I can't contribute a fix, but feel free to use the above as a test case if this is unintended :)

@JohnnyMorganz JohnnyMorganz added the bug Something isn't working label Mar 30, 2023
@JohnnyMorganz
Copy link
Owner

Definitely unintended, let me take a look. Thanks for the report!

@JohnnyMorganz
Copy link
Owner

This has been fixed and is available in v0.17.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants