-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/gofmt: odd comment alignment #9064
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
Comments
Owner changed to @griesemer. Status changed to Accepted. |
@cznic I believe your hypothesis is correct. The following example https://play.golang.org/p/-4qfL0qblf7 exhibits the same problem and the alignment of the 3rd foo is based on the string length of the raw string on the next line (the |
The fix is probably to recognize newlines in escaped text sequences in the tabwriter and then flush the buffer contents up to the newline but keep the escape mode on: No matter the previous content, when the escaped text sequence containing a newline is written out, the resulting line break is going to break the existing formatting/column alignment. This should probably only be done if enabled by a new flag in order to not break existing code that might rely on the current behavior. go/printer then would simply have to set that flag. Probably not too hard to do but requires thorough understanding of tabwriter internals (which is somewhat subtle). Marking for 1.11 in case I find the muse to do it. Not urgent. |
Change https://golang.org/cl/105040 mentions this issue: |
The text was updated successfully, but these errors were encountered: