Skip to content
Merged
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