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

fmt: fix enum/struct_decl/struct_init fields with empty newlines #22051

Merged
merged 2 commits into from
Aug 15, 2024

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Aug 15, 2024

This PR fix enum/struct_decl/struct_init fields with empty newlines.

  • Fix enum/struct_decl/struct_init fields with empty newlines.
  • Add tests.
module abcde

pub struct Builder {
pub mut:
	// inline before field
	buf          []u8
	str_calls    int
	len          int
	initial_size int = 1
}

pub fn new_builder(initial_size int) Builder {
	return Builder{
		// buf: make(0, initial_size)
		buf: []u8{cap: initial_size}

		// before comment
		str_calls: 0 // after str_calls
		len:       0 // after len

		// before comment1
		// before comment2
		initial_size: initial_size // final
	}
}
module main

fn main() {
}

pub struct OperateInfo { // implements IperateInfo
pub mut:
	title string // title

	// msg, id
	msg string // msg
	id  string // id

	// other1
	// other2
	other string
} // operate info
enum Info {
	aa = 1 // aa
	bbb // bbb

	cccc = 5 /* cccc
	--- cccc
	*/
	ddddd = 10 // ddddd

	// before
	ee  = 20
	fff = 30

	// before comment1
	// before comment2
	gg
}

fn main() {}

@spytheman spytheman merged commit 4bce71e into vlang:master Aug 15, 2024
72 of 73 checks passed
@JalonSolov
Copy link
Contributor

Hmm... I'd disagree with

	aa = 1 // aa
	bbb // bbb

I think it should be

	aa = 1 // aa
	bbb    // bbb

Even though there is no initializer on bbb, it is still next to aa with no blank lines or comments between them.

@yuyi98 yuyi98 deleted the fix_fmt_struct_field_newline branch August 16, 2024 00:56
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.

3 participants