[Formatter] Add trailing comma after last element in multiline call argument list#17018
Draft
Sija wants to merge 4 commits into
Draft
[Formatter] Add trailing comma after last element in multiline call argument list#17018Sija wants to merge 4 commits into
Sija wants to merge 4 commits into
Conversation
edfd61f to
a32b907
Compare
Member
|
This looks like the kind of formatter change that we should guard behind a flag and enable in bulk (ref. #13002). |
2f9aa48 to
98034f0
Compare
98034f0 to
032b3ca
Compare
Contributor
Author
|
I believe I've fixed all edge cases; This PR is ready for another round of review. The matter of guarding this change behind the flag is left out for now, until we find a suitable way of moving forward with it. |
| assert_format "foo(\n 1,\n &block\n)" | ||
| assert_format "foo \\\n 1,\n bar: 2" | ||
| assert_format "foo \\\n 1" | ||
| assert_format "foo(\n 1,\n bar: <<-HEREDOC\n foo\n HEREDOC\n)" |
Member
There was a problem hiding this comment.
question: Shouldn't we add a comma here?
Suggested change
| assert_format "foo(\n 1,\n bar: <<-HEREDOC\n foo\n HEREDOC\n)" | |
| assert_format "foo(\n 1,\n bar: <<-HEREDOC\n foo\n HEREDOC\n)", "foo(\n 1,\n bar: <<-HEREDOC,\n foo\n HEREDOC\n)" |
Btw. we might want to use heredocs for the strings to makes the examples easier to read.
Contributor
Author
|
It seems I've found a bug in the current formatter (Crystal v1.20.2): foo(
<<-HEREDOC,
foo
HEREDOC
)gets formatted to: foo(
<<-HEREDOC
foo
HEREDOC
,
)The same happens for a named argument as well. |
Contributor
Author
|
@straight-shoota Should I create a new issue re: the above formatter bug? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before
After
Refs #13169
Refs crystal-ameba/ameba#833