Skip to content

fmt: fix comment line number in file with crlf line separator#25163

Merged
spytheman merged 4 commits into
vlang:masterfrom
Krchi:fix-vfmt-off-in-crlf
Aug 24, 2025
Merged

fmt: fix comment line number in file with crlf line separator#25163
spytheman merged 4 commits into
vlang:masterfrom
Krchi:fix-vfmt-off-in-crlf

Conversation

@Krchi

@Krchi Krchi commented Aug 24, 2025

Copy link
Copy Markdown
Contributor

fix #23524
file with crlf line separator will replace with lf after format
#23629 it could be same problem

krchi added 2 commits August 24, 2025 10:51
@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-23924

@spytheman

Copy link
Copy Markdown
Contributor

Please add a test case.

@spytheman

Copy link
Copy Markdown
Contributor

The test can be a pair of xxx_input.vv/xxx_expected.vv files, where the input version has the CRLF line endings (you can check with xxd).

@spytheman

spytheman commented Aug 24, 2025

Copy link
Copy Markdown
Contributor

You will probably also need to add an vlib/v/fmt/tests/.gitattributes file, similar to ./vlib/v/checker/tests/.gitattributes, which contains:

*_crlf_*  binary
*_lf_*    binary

so that git will then know to not auto convert the CRLFs in the input to just LFs

@spytheman

Copy link
Copy Markdown
Contributor

#23629 it could be same problem

It could be, although I think that it is playground specific.
If I remember correctly it had to do with how the JS code for the frontend there treated the server responses, but I could be wrong.

@spytheman

Copy link
Copy Markdown
Contributor

hm, sorry; I will add the test, since it mostly works locally

@Krchi

Krchi commented Aug 24, 2025

Copy link
Copy Markdown
Contributor Author

hm, sorry; I will add the test, since it mostly works locally

You are right, this test case is hard for me

@spytheman

Copy link
Copy Markdown
Contributor

It was indeed tricky to add, since I also had a git hook to always run vfmt on the changed .vv files :-) too; I had to git commit --no-verify to avoid it explicitly...

Comment thread vlib/v/scanner/scanner.v

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work!

@spytheman spytheman merged commit 000b416 into vlang:master Aug 24, 2025
83 checks passed
@Krchi Krchi deleted the fix-vfmt-off-in-crlf branch November 13, 2025 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vfmt inconsistency between CRLF and LF end of line

2 participants