-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 alignment of struct fields init #22000
Conversation
In my personal opinion, that does not seem like a clear improvement 🤔 . Previously, I could just With the new changes, that would not work, since there could be an arbitrary amount of spaces after the name, so the search regexp would have to become more complex. Visually, it does help to align unrelated expressions, but that to me, makes it a bit harder to read, especially, when there is a long field name somewhere, that will force all the other field expressions to shift farther right. The reader will then have to scan a lot of white space between the field name and the expression for it, in a list, which to me will increase the chance of reading mistakes. |
Is this style OK? return Args{
bytes: bytes_arg
follow: if f_arg { 'descriptor' } else { follow_arg }
lines: lines_arg
max_unchanged_stats: max_unchanged_stats_arg
} |
Another reason to dislike this, for me, is that it increases the chances of bigger diffs in remote places, for unrelated changes, just due to formatting. See for example https://github.com/vlang/v/pull/22000/files#diff-053e81e58870190b51e3f9c9bd0271125f412ace9be8798baa0ae745db4036f2L157-L167 In that diff, the longest field is named In comparison, with the current fmt version on master, changing that field in the same way, will only require local changes to the lines, that do mention the old name, without affecting the rest -> much smaller diffs, that are easier to read, with minimal chances for conflicts. |
No, the position of the |
@medvednikov what do you think? Do you prefer for fmt to produce struct initializations, with aligned field values or not? |
Sorry for the delay. We should mimic gofmt's behavior here. This is ok:
Except there needs to be only one space after |
Also gofmt doesn't align the values if there's a newline or a comment. |
Can we close this, since #22025 was merged? |
This PR fix alignment of struct fields init.