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

Handle trailing comma with multiple parameters on the same line #15097

Open
wants to merge 1 commit into
base: release/1.14
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions spec/compiler/formatter/formatter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,13 @@ describe Crystal::Formatter do
end
CRYSTAL

assert_format <<-CRYSTAL
def foo(
a, b,
)
end
CRYSTAL

assert_format <<-CRYSTAL
macro foo(
a,
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/tools/formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ module Crystal
yield

# Write "," before skipping spaces to prevent inserting comment between argument and comma.
write "," if has_more || (wrote_newline && @token.type.op_comma?) || (write_trailing_comma && flag?("def_trailing_comma"))
write "," if has_more || (wrote_newline && @token.type.op_comma?) || (write_trailing_comma && flag?("def_trailing_comma")) || (write_trailing_comma && @token.type.op_comma?)

just_wrote_newline = skip_space
if @token.type.newline?
Expand Down
Loading