From 23f5147e4537b49c736772c609a5da4674d8b25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Thu, 2 Feb 2023 19:07:01 +0100 Subject: [PATCH] Fix formatter not merge consecutive but separated comment lines (#12909) --- spec/compiler/formatter/formatter_spec.cr | 1 + src/compiler/crystal/tools/formatter.cr | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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