Skip to content

Fix blank lines inserted between consecutive comment lines#49

Merged
jdeniau merged 1 commit intomapado:mainfrom
kwintenvdberghe:fix/multi-line-comment-blank-lines
May 8, 2026
Merged

Fix blank lines inserted between consecutive comment lines#49
jdeniau merged 1 commit intomapado:mainfrom
kwintenvdberghe:fix/multi-line-comment-blank-lines

Conversation

@kwintenvdberghe
Copy link
Copy Markdown
Contributor

@kwintenvdberghe kwintenvdberghe commented May 4, 2026

Closes #32

Summary

When a # comment block leads a step that requires a leading hardline (e.g. with forceNewlineBetweenStepBlocks: true, or when there was already a blank line before the previous step), every comment in the block currently has a hardline prepended individually. Prettier joins leading own-line comments with its own hardline, so the result is a blank line inserted between every consecutive comment line.

This change makes only the first comment in a contiguous leading block prepend the hardline; subsequent comments rely on prettier's join. Multi-line # comment blocks now stay together as a single block with at most one blank line in front of them.

A new fixture tests/plugin/multiple_comments_line_before_step.feature covers the case (a multi-line comment block leading a Given after a When, exercised against forceNewlineBetweenStepBlocks: true). The existing multiple_comments_line.feature snapshot is unchanged.

Test plan

  • yarn test — 54/54 pass
  • Verified the new snapshot reflects the fix (single blank line before the comment block; no blank lines between comments) and that without the patch the same fixture produces a blank line between every comment

🤖 Generated with Claude Code

When a comment block leads a step that requires a leading hardline
(e.g. with `forceNewlineBetweenStepBlocks: true`), only the first
comment in the contiguous block now prepends the hardline. Subsequent
comments rely on prettier's own join between leading own-line comments,
so multi-line comment blocks no longer get blank lines inserted between
every line.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@jdeniau jdeniau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thanks for this fix.

@kwintenvdberghe
Copy link
Copy Markdown
Contributor Author

Thanks for approving @jdeniau!

When do you think this could get merged? We are currently manually patching this in our repo, but ideally we can get rid of that patch once this has been released.

@jdeniau jdeniau merged commit ec48c7c into mapado:main May 8, 2026
3 checks passed
@jdeniau
Copy link
Copy Markdown
Member

jdeniau commented May 8, 2026

3.1.4 is released 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid newline between two existing comment lines

2 participants