Skip to content

Commit

Permalink
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions spec/compiler/formatter/formatter_spec.cr
Original file line number Diff line number Diff line change
@@ -344,6 +344,7 @@ describe Crystal::Formatter do
assert_format "a = case 1\nwhen 2\n3\nelse\n4\nend", "a = case 1\n when 2\n 3\n else\n 4\n end"
assert_format "a = \nif 1\n2\nend", "a =\n if 1\n 2\n end"
assert_format "a, b = \nif 1\n2\nend", "a, b =\n if 1\n 2\n end"
assert_format "a = b = 1\na, b =\n b, a"

assert_format %(require "foo"), %(require "foo")

11 changes: 8 additions & 3 deletions src/compiler/crystal/tools/formatter.cr
Original file line number Diff line number Diff line change
@@ -3510,14 +3510,19 @@ module Crystal

write_token " ", :"="
skip_space
if @token.type == :NEWLINE && node.values.size == 1
if @token.type == :NEWLINE
next_token_skip_space_or_newline
write_line
write_indent(@indent + 2, node.values.first)
if node.values.size == 1
write_indent(@indent + 2, node.values.first)
return false
else
write_indent(@indent + 2)
end
else
write " "
format_mutli_assign_values node.values
end
format_mutli_assign_values node.values

false
end

0 comments on commit 7cdf9e3

Please sign in to comment.