Skip to content

Commit 0c3c3d4

Browse files
committedJun 3, 2017
Formatter: fix removal of newline when it had spaces
1 parent ddc3cb3 commit 0c3c3d4

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
 

‎spec/compiler/formatter/formatter_spec.cr

+2
Original file line numberDiff line numberDiff line change
@@ -1020,4 +1020,6 @@ describe Crystal::Formatter do
10201020
assert_format "def a\n b(\n 1, # x\n # y\n a: 1, # x\n # y\n b: 2 # z\n )\nend"
10211021

10221022
assert_format "def foo(a, **b : Int32)\nend"
1023+
1024+
assert_format "foo\n \nbar", "foo\n\nbar"
10231025
end

‎src/compiler/crystal/tools/formatter.cr

+2-1
Original file line numberDiff line numberDiff line change
@@ -4139,7 +4139,7 @@ module Crystal
41394139
def consume_newlines
41404140
if @token.type == :NEWLINE
41414141
write_line
4142-
next_token
4142+
next_token_skip_space
41434143

41444144
if @token.type == :NEWLINE
41454145
write_line
@@ -4210,6 +4210,7 @@ module Crystal
42104210
else
42114211
@column += string.size
42124212
end
4213+
42134214
@wrote_newline = false
42144215
@last_write = string
42154216
end

0 commit comments

Comments
 (0)
Please sign in to comment.