Keep the indent level after an inline comment in a value group - #19874
Open
Kjubikstronk wants to merge 2 commits into
Open
Keep the indent level after an inline comment in a value group#19874Kjubikstronk wants to merge 2 commits into
Kjubikstronk wants to merge 2 commits into
Conversation
A comma group inside a paren group indents its own contents, and the paren group indents too. That was compensated by dedenting the single hardline after the comment, so the comment landed correctly but everything following it stayed one level too deep. Skip the group's own indent instead, since the paren group already provides one.
✅ Deploy Preview for prettier ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19427.
Description
An inline comment inside a function's arguments pushed everything after it one indent level too deep, and left the closing parens asymmetric:
Without the comment the same value indents in clean steps of two and closes symmetrically; the comment is the only difference.
Cause
A
value-comma_groupreturnsgroup(indent(fill(parts))), and when it sits inside a paren group that paren group indents as well. That double indent was being compensated by dedenting the single line break after the comment:That fixes the comment's own line, which is why the comment looks right, but the extra level is still open for everything after it — so the following argument and every nested call inside it are shifted, and the closing parens unwind from the wrong depth.
The comma group only exists here because of the comment: without one, the arguments are printed directly by the paren group with no wrapper.
Change
Drop the group's own indent when it holds an inline comment and its parent already indents, instead of dedenting one line inside it:
The
dedent(hardline)special case goes away with it, since the level it was compensating for is no longer added.Tests
tests/format/scss/comments/19427.scsscovers the reported input plus a comment before a plain argument.One existing snapshot changed,
4878.scss, which covers this same construct. It was recording the bug — the old output stepped8 → 12across the comment and closed at mismatched depths, the new one steps8 → 10 → 12and closes symmetrically. Worth a look in the diff to confirm you agree it is the improvement it looks like.tests/format/{css,scss,less}: 559 tests, 545 snapshots — only that one snapshot changed.main— threejsxsuites andpatterns-dirs.jsfail identically with this change stashed, andcache.jspasses standalone both with and without it (65.9s vs 65.8s), only timing out under full-suite parallel load.Checklist
docs/directory).changelog_unreleased/*/XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.To be explicit rather than leaving it to an unticked box: this PR was written with AI assistance, and reviewed before submitting.