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

cmd/gofmt: allow same level indent for block comments #38204

Open
dsnet opened this issue Apr 1, 2020 · 3 comments
Open

cmd/gofmt: allow same level indent for block comments #38204

dsnet opened this issue Apr 1, 2020 · 3 comments
Assignees
Milestone

Comments

@dsnet
Copy link
Member

@dsnet dsnet commented Apr 1, 2020

Given the following code:

/*
someDisabledCode()
*/

It will be reformatted as:

/*
	someDisabledCode()
*/

(notice the indent it injects)

This is frustrating for users who need to maintain patches since it means that there is now a potentially massive diff when trying to comment large blocks of code in a patch.

Would it be possible for gofmt to stop trying to indent everything within the block comments?

\cc @griesemer

@griesemer
Copy link
Contributor

@griesemer griesemer commented Apr 1, 2020

@dsnet Yes, it would be possible :-)

It was probably a mistake to try to "adjust" comments in any way with gofmt, but it also has been like this for > 10 years. We could try to just leave comments alone. It shouldn't have an effect on existing code since it would simply remain untouched.

\cc @rsc for another opinion.

@griesemer griesemer self-assigned this Apr 1, 2020
@griesemer griesemer added this to the Unplanned milestone Apr 1, 2020
@dsnet
Copy link
Member Author

@dsnet dsnet commented Apr 2, 2020

but it also has been like this for > 10 years

Yep, and every year, I've probably been annoyed by this behavior. It took till now for me to file an issue about it ;)

@mvdan
Copy link
Member

@mvdan mvdan commented Apr 3, 2020

This gets a thumbs up from me too. Though I have to admit, I only ever use /* comments to comment out chunks of code without affecting the diff too much (modulo this issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.