diff --git a/spec/compiler/formatter/formatter_spec.cr b/spec/compiler/formatter/formatter_spec.cr index 7dfa16e1bb16..aa012b32a5f3 100644 --- a/spec/compiler/formatter/formatter_spec.cr +++ b/spec/compiler/formatter/formatter_spec.cr @@ -1309,6 +1309,7 @@ describe Crystal::Formatter do assert_format "# foo\na = 1 # bar" assert_format "#### ###" assert_format "#######" + assert_format "x\n# foo\n\n# bar" assert_format "A = 1\nFOO = 2\n\nEX = 3", "A = 1\nFOO = 2\n\nEX = 3" assert_format "FOO = 2\nA = 1", "FOO = 2\nA = 1" diff --git a/src/compiler/crystal/tools/formatter.cr b/src/compiler/crystal/tools/formatter.cr index cb7206470291..16688fa4331e 100644 --- a/src/compiler/crystal/tools/formatter.cr +++ b/src/compiler/crystal/tools/formatter.cr @@ -4778,7 +4778,7 @@ module Crystal @wrote_double_newlines = true end - skip_space_or_newline + skip_space_or_newline(last: next_comes_end, at_least_one: true) end end