Skip to content

Track blank-line-before in single-line comments to preserve consecutive grouping#165

Merged
webdevred merged 3 commits intomasterfrom
consecutive-comments
Mar 10, 2026
Merged

Track blank-line-before in single-line comments to preserve consecutive grouping#165
webdevred merged 3 commits intomasterfrom
consecutive-comments

Conversation

@webdevred
Copy link
Owner

Add cHadNewlineBefore field to InternalComment to record whether a single-line // comment was preceded by a blank line (2+ newlines) in the source. The parser's separatorParser now counts total newlines to detect blank lines and stores the result in ParseState.

The formatter uses this to suppress the extra blank line before a // comment when it directly follows another // comment with no blank line between them in the source, preserving the original grouping of consecutive comments.

Add `cHadNewlineBefore` field to `InternalComment` to record whether a
single-line `//` comment was preceded by a blank line (2+ newlines) in
the source. The parser's `separatorParser` now counts total newlines to
detect blank lines and stores the result in `ParseState`.

The formatter uses this to suppress the extra blank line before a `//`
comment when it directly follows another `//` comment with no blank line
between them in the source, preserving the original grouping of
consecutive comments.
@webdevred webdevred merged commit 451611a into master Mar 10, 2026
12 checks passed
@webdevred webdevred deleted the consecutive-comments branch March 10, 2026 19:25
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.

1 participant