cmd/gofmt: multiline function arguments are inconsistently indented #39586
Comments
I don't see the indentation you describe. I see f((some
multiline
arg),
(another
multline
arg)) This seems consistent even if it is odd in this example. Each continuation is indented one tab stop from the start of the sequence. |
Yes, that particular example was misleading because I meant for pieces of each arg to be internally indented (and "arg" behaves differently if it is a closing delimiter). The case I'm trying to avoid is this:
which is confusing. Yes, I get that this is just what happens when the indentation of individual function args is independent of the indentation of the function arg list, but I don't see what would be harmed if, when a multiline arg starts on the first line of the function call and some other arg uses the function arg list's indentation, the continuation of the first multiline arg (and subsequent args following its indentation) were additionally indented by the function arg list's indentation. So you would have this:
|
Given @ianlancetaylor 's example, it's worth thinking about whether this behavior (when the last line of the arg doesn't start with a closing delimiter) is desirable:
|
What version of Go are you using (
go version
)?The playground reports that it's using go1.14.3.
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?The playground hides this information.
What did you do?
Format a function call with multiline arguments:
https://play.golang.org/p/UefV4IrB2C2
What did you expect to see?
Each multiline argument's continuation lines to be indented the same amount:
What did you see instead?
The continuation lines of the multiline argument that starts on the same line as the function call are not indented, but the remaining arguments are:
The text was updated successfully, but these errors were encountered: