bugfix(formatter): Made all single line comment prevent removing line-breaks. - #10045
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR SummaryLow Risk Overview
Reviewed by Cursor Bugbot for commit 4670b30. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6782dc31c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
f6782dc to
4670b30
Compare
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 5 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on eytan-starkware and orizi).
orizi
left a comment
There was a problem hiding this comment.
@orizi resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

Summary
Fixes the Cairo formatter incorrectly collapsing match arm bodies that contain doc comments (
///) or inner comments (//!) into a single line, stripping the comment in the process. The fix updatesis_statement_list_break_point_optionalto check forTokenSingleLineComment,TokenSingleLineDocComment, andTokenSingleLineInnerCommentsyntax kinds directly, rather than walking throughTrivianodes and checking forSingleLineCommenttrivium variants (which did not cover doc/inner comment token kinds). A test case covering both///and//!in match arm bodies is added.Type of change
Please check one:
Why is this change needed?
Match arm bodies containing doc comments (
///) or inner comments (//!) were being incorrectly treated as candidates for collapsing to a single line. The previous check only recognizedast::Trivium::SingleLineComment, missing the doc and inner comment token kinds, so those comments were silently dropped when the formatter collapsed the block.What was the behavior or documentation before?
A match arm like:
would be incorrectly formatted (the comment was dropped and the block collapsed).
What is the behavior or documentation after?
Match arm bodies containing
///or//!comments are preserved as multi-line blocks, keeping the comment intact:Related issue or discussion (if any)
N/A
Additional context
The
format_leading_commentdoc comment was also updated to clarify that the formatter only merges continuation lines it broke off from over-long open lines, not lines the user wrote separately.