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

Formatter removes lines (1 per formatting) after scope block in function body #22900

Closed
ttytm opened this issue Nov 18, 2024 · 2 comments · Fixed by #22903
Closed

Formatter removes lines (1 per formatting) after scope block in function body #22900

ttytm opened this issue Nov 18, 2024 · 2 comments · Fixed by #22903
Labels
Bug This tag is applied to issues which reports bugs. Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V.

Comments

@ttytm
Copy link
Member

ttytm commented Nov 18, 2024

Describe the bug

When using a block to encapsulate some logic in a function, v fmt removes the lines after it in an inconsistent way.

Reproduction Steps

Format below:

fn main() {
	{
		println('(1/3) My first small scope')
		//
	}


	{
		println('(2/3) My second small scope')
		//
	}
	// A line below prevents the line removal

	{
		println('(3/3) My Third small scope')
	}
}

v fmt

fn main() {
	{
		println('(1/3) My first small scope')
		//
	}

-												
 	{
		println('(2/3) My second small scope')
		//
	}
	// A line below prevents the line removal

	{
		println('(3/3) My Third small scope')
	}
}

vfmt

fn main() {
	{
		println('(1/3) My first small scope')
		//
	}
-												
	{
		println('(2/3) My second small scope')
		//
	}
	// A line below prevents the line removal

	{
		println('(3/3) My Third small scope')
	}
}

Expected Behavior

Keep one line after a block when it is followed by multiple empty lines and it's not the end of the function body.

Current Behavior

above

Possible Solution

No response

Additional Information/Context

No response

V version

v0.4.8

Environment details (OS name and version, etc.)

linux

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.

Huly®: V_0.6-21343

@ttytm ttytm added Bug This tag is applied to issues which reports bugs. Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V. labels Nov 18, 2024
@spytheman
Copy link
Member

I think that it just collapses multiple empty lines into 1 empty line.

@spytheman
Copy link
Member

It should stabilize after 1 run though, it should not oscillate or have to be run multiple times in a row.

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. Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants