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 · 4 comments
Open

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

dsnet opened this issue Apr 1, 2020 · 4 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@dsnet
Copy link
Member

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

@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
@griesemer griesemer added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 1, 2020
@dsnet
Copy link
Member Author

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 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).

@hrissan
Copy link

hrissan commented Dec 17, 2022

This also frustrates me, because additional indent destroys "blame" for all commented lines.

Looking forward for the fix)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants