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

The first line after // vfmt off is replaced with // vfmt on if the first line ends with a comment #23629

Open
revosw opened this issue Feb 2, 2025 · 3 comments
Labels
Bug This tag is applied to issues which reports bugs. OS: Playground Bugs/feature requests, that are specific to play.vlang.io. Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V.

Comments

@revosw
Copy link

revosw commented Feb 2, 2025

Describe the bug

The first line after // vfmt off is replaced with // vfmt on if the first line ends with a comment.

Reproduction Steps

Code: https://play.vlang.io/p/472fc92506

fn main() {
	// vfmt off
	num := 4 // some comment
	// vfmt on
}

Format the code using the format button in the playground link, or run v fmt -w on the file

Expected Behavior

The code is left untouched:

fn main() {
	// vfmt off
	num := 4 // some comment
	// vfmt on
}

Current Behavior

Output:

fn main() {
	// vfmt off
	// vfmt on
	// vfmt on
}

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.9 b91bbad

Environment details (OS name and version, etc.)

|V full version      |V 0.4.9 b91bbad
|:-------------------|:-------------------
|OS                  |linux, Debian GNU/Linux 12 (bookworm) (VM)
|Processor           |2 cpus, 64bit, little endian, Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz
|Memory              |1.24GB/2.02GB
|                    |
|V executable        |/home/admin/v/v
|V last modified time|2025-01-31 21:25:26
|                    |
|V home dir          |OK, value: /home/admin/v
|VMODULES            |OK, value: .vmodules
|VTMP                |OK, value: /tmp/v_0
|Current working dir |OK, value: /home/admin/playground
|                    |
|Git version         |git version 2.39.5
|V git status        |Error: fatal: detected dubious ownership in repository at '/home/admin/v'
To add an exception for this directory, call:

	git config --global --add safe.directory /home/admin/v
|.git/config present |true
|                    |
|cc version          |cc (Debian 12.2.0-14) 12.2.0
|gcc version         |gcc (Debian 12.2.0-14) 12.2.0
|clang version       |Debian clang version 14.0.6
|tcc version         |tcc version 0.9.28rc 2024-07-31 HEAD@1cee0908 (x86_64 Linux)
|tcc git status      |Error: fatal: detected dubious ownership in repository at '/home/admin/v/thirdparty/tcc'
To add an exception for this directory, call:

	git config --global --add safe.directory /home/admin/v/thirdparty/tcc
 Error: fatal: detected dubious ownership in repository at '/home/admin/v/thirdparty/tcc'
To add an exception for this directory, call:

	git config --global --add safe.directory /home/admin/v/thirdparty/tcc

|emcc version        |N/A
|glibc version       |ldd (Debian GLIBC 2.36-9+deb12u8) 2.36

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.

@revosw revosw added the Bug This tag is applied to issues which reports bugs. label Feb 2, 2025
Copy link

Connected to Huly®: V_0.6-22053

@spytheman spytheman added the Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V. label Feb 2, 2025
@spytheman
Copy link
Member

I can not reproduce it with the code from the issue, but the one from the playground triggers the bug:

enum Enum {
	// vfmt off
	entry // comment
	// vfmt on
}

becomes:

enum Enum {
	// vfmt off
	// vfmt on
	// vfmt on
}

after running v fmt -w file.v

@spytheman spytheman added the Enums Bugs involving enumerations. label Feb 2, 2025
@spytheman
Copy link
Member

Locally the enums work too.

I think, that it is specific to the playground:
Image

@spytheman spytheman added OS: Playground Bugs/feature requests, that are specific to play.vlang.io. Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V. and removed Enums Bugs involving enumerations. Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V. labels Feb 2, 2025
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. OS: Playground Bugs/feature requests, that are specific to play.vlang.io. 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