Skip to content

Commit

Permalink
Format: fix comment indentation in case's else (#6393)
Browse files Browse the repository at this point in the history
Fix #6391
  • Loading branch information
makenowjust authored and RX14 committed Jul 16, 2018
1 parent 210d8ef commit 466e0a2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions spec/compiler/formatter/formatter_spec.cr
Expand Up @@ -899,6 +899,7 @@ describe Crystal::Formatter do
assert_format "return 1\n# end"
assert_format "case\n# hello\nwhen 1\n 2\nend"
assert_format "case 1\nwhen 2 # a\n # b\nend"
assert_format "case 1\nelse # foo\n # bar\nend"

assert_format "{} of A => B\n{} of Foo => Bar"

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/tools/formatter.cr
Expand Up @@ -3367,7 +3367,7 @@ module Crystal
if a_else = node.else
write_indent
write_keyword :else
found_comment = skip_space
found_comment = skip_space(@indent + 2)
if @token.type == :NEWLINE || found_comment
write_line unless found_comment
format_nested(a_else)
Expand Down

0 comments on commit 466e0a2

Please sign in to comment.