Skip to content

Commit

Permalink
Fix formatting multiline literal elements (#7048)
Browse files Browse the repository at this point in the history
Fixed #7046
  • Loading branch information
makenowjust authored and RX14 committed Nov 11, 2018
1 parent 3025fef commit 52b2e6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions spec/compiler/formatter/formatter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ describe Crystal::Formatter do
assert_format "[1,\n2,\n3]", "[1,\n 2,\n 3]"
assert_format "[1,\n2,\n3\n]", "[1,\n 2,\n 3,\n]"
assert_format "[\n1,\n2,\n3]", "[\n 1,\n 2,\n 3,\n]"
assert_format "[\n [\n 1,\n ], [\n 2,\n ], [\n 3,\n ],\n]"
assert_format "[\n {\n 1 => 2,\n }, {\n 3 => 4,\n }, {\n 5 => 6,\n },\n]"
assert_format "if 1\n[ 1 , 2 , 3 ]\nend", "if 1\n [1, 2, 3]\nend"
assert_format " [ 1, \n 2 , \n 3 ] ", "[1,\n 2,\n 3]"
assert_format "Set { 1 , 2 }", "Set{1, 2}"
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 @@ -820,7 +820,7 @@ module Crystal
if next_needs_indent
write_indent(offset, element)
else
accept element
indent(offset, element)
end

has_heredoc_in_line = !@lexer.heredocs.empty?
Expand Down

0 comments on commit 52b2e6b

Please sign in to comment.