Skip to content
Permalink
Browse files
Format: fix #4620, to format /= after else in case (#4627)
`skip_space_or_newline` is not needed because it is called inside
`format_nested`.
  • Loading branch information
makenowjust authored and RX14 committed Sep 10, 2017
1 parent 46197bd commit 203ab9f7a571c9f8fd39c3b777a5e89fe331947d
Showing with 3 additions and 6 deletions.
  1. +1 −0 spec/compiler/formatter/formatter_spec.cr
  2. +2 −6 src/compiler/crystal/tools/formatter.cr
@@ -460,6 +460,7 @@ describe Crystal::Formatter do
assert_format "case 1 \n when .foo? \n 3 \n end", "case 1\nwhen .foo?\n 3\nend"
assert_format "case 1\nwhen 1 then\n2\nwhen 3\n4\nend", "case 1\nwhen 1\n 2\nwhen 3\n 4\nend"
assert_format "case 1 \n when 2 \n 3 \n else 4 \n end", "case 1\nwhen 2\n 3\nelse 4\nend"
assert_format "a = 1\ncase\nwhen 2\nelse\n a /= 3\nend"

assert_format "select \n when foo \n 2 \n end", "select\nwhen foo\n 2\nend"
assert_format "select \n when foo \n 2 \n when bar \n 3 \n end", "select\nwhen foo\n 2\nwhen bar\n 3\nend"
@@ -3277,12 +3277,8 @@ module Crystal
write_keyword :else
found_comment = skip_space
if @token.type == :NEWLINE || found_comment
unless found_comment
write_line
next_token
end
skip_space_or_newline(@indent + 2)
format_nested(a_else, @indent)
write_line unless found_comment
format_nested(a_else)
skip_space_or_newline(@indent + 2)
else
while @token.type == :";"

0 comments on commit 203ab9f

Please sign in to comment.