From 53b90c80774112451bf8d5bd8bcbc956d242717e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Fri, 6 Jan 2023 12:53:45 +0100 Subject: [PATCH] Fix formatter not merge consecutive but separated comment lines --- 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 abcbac598c29..6e6a8895fcd8 100644 --- a/spec/compiler/formatter/formatter_spec.cr +++ b/spec/compiler/formatter/formatter_spec.cr @@ -1129,6 +1129,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 c2bc17cec2ea..0362ce960834 100644 --- a/src/compiler/crystal/tools/formatter.cr +++ b/src/compiler/crystal/tools/formatter.cr @@ -4762,7 +4762,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