bugfix(formatter): keep parameter-list comment formatting idempotent#10208
bugfix(formatter): keep parameter-list comment formatting idempotent#10208futurehua wants to merge 1 commit into
Conversation
Signed-off-by: futurehua <futurehua@outlook.com>
PR SummaryLow Risk Overview In Adds a Reviewed by Cursor Bugbot for commit 779c41b. Bugbot is set up for automated code reviews on this repo. Configure here. |
Summary
Fix formatter non-idempotence for line comments inside parameter lists.
Leading comments that remain on the current line now receive a separating space when neither an existing space nor a pending breakpoint already provides one. A regression fixture verifies both the expected output and formatter idempotence.
Fixes #10139.
Type of change
Please check one:
Why is this change needed?
Comments inside parameter lists are represented as leading trivia of the following token. When the associated breakpoint remains unbroken, the formatter previously emitted no separator before some of these comments.
As a result, the first formatting pass produced output such as:
Reparsing that output classified the comments differently, so a second formatting pass inserted spaces. This violated the formatter's idempotence guarantee and caused editor, pre-commit, and CI formatting results to disagree.