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

vfmt inconsistency between CRLF and LF end of line #23524

Open
AlphaByte02 opened this issue Jan 19, 2025 · 2 comments
Open

vfmt inconsistency between CRLF and LF end of line #23524

AlphaByte02 opened this issue Jan 19, 2025 · 2 comments
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V.

Comments

@AlphaByte02
Copy link

AlphaByte02 commented Jan 19, 2025

Describe the bug

If u "disable" fmt with // vfmt off and after reenable it with // vfmt on on a block on a file with CRLF as end of line v fmt delete the line under // vfmt off and add a new // vfmt on after the already existing // vfmt on breaking the code.
On a file with LF as eol this problem doesn't subsist.

Reproduction Steps

Create a simple file like:

module main

fn main() {
	// vfmt off
	a := [
		1, 2, 3,
		4, 5, 6,
	]
	// vfmt on

	println('Hello World!')
}

And set the eol as CRLF

Expected Behavior

Running v fmt . nothing change as all is already formatted and/or you want to keep the style as is.
v fmt should not act differently based of the eol.

Current Behavior

With CRLF eol.
Running v fmt . (from ide or terminal) break the code returning this:

fn main() {
        // vfmt off
                1, 2, 3,
                4, 5, 6,
        ]
        // vfmt on
        // vfmt on
        println('Hello World!')
}

Possible Solution

No response

Additional Information/Context

Setting the file to LF eol resolve the issue.
I dont think that the problem could be the terminal used (Win Terminal) because using v fmt -w . write the wrong output on the file.

V version

V 0.4.9 2aa5651.fda0af4

Environment details (OS name and version, etc.)

V full version V 0.4.9 2aa5651.fda0af4
OS windows, Microsoft Windows 11 Pro 22621 64-bit
Processor 24 cpus, 64bit, little endian, 13th Gen Intel(R) Core(TM) i7-13700K
Memory 22.48GB/31.78GB
V executable E:\Coding\v\v\v.exe
V last modified time 2025-01-19 13:39:47
V home dir OK, value: E:\Coding\v\v
VMODULES OK, value: C:\Users\Alpha\.vmodules
VTMP OK, value: C:\Users\Alpha\AppData\Local\Temp\v_0
Current working dir OK, value: E:\Coding\v\testfmt
Git version git version 2.47.1.windows.1
V git status weekly.2025.1-84-gfda0af48
.git/config present true
cc version N/A
gcc version N/A
clang version N/A
msvc version N/A
tcc version tcc version 0.9.27 (x86_64 Windows)
tcc git status N/A
emcc version N/A
glibc version N/A

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@AlphaByte02 AlphaByte02 added the Bug This tag is applied to issues which reports bugs. label Jan 19, 2025
Copy link

Connected to Huly®: V_0.6-21952

@spytheman spytheman added Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V. labels Jan 23, 2025
@spytheman
Copy link
Member

Excellent find. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V.
Projects
None yet
Development

No branches or pull requests

2 participants