Skip to content

fix: preserve walrus comments across formatter passes#520

Open
msaule wants to merge 1 commit into
posit-dev:mainfrom
msaule:fix-walrus-comment-idempotence
Open

fix: preserve walrus comments across formatter passes#520
msaule wants to merge 1 commit into
posit-dev:mainfrom
msaule:fix-walrus-comment-idempotence

Conversation

@msaule

@msaule msaule commented Jul 22, 2026

Copy link
Copy Markdown

Fixes #512.

Summary

Preserve an own-line comment between := and its RHS so that formatting is idempotent. Comment-free walrus line breaks and end-of-line comments retain Air's existing compact canonical output.

Root cause

Walrus formatting intentionally flattens ordinary line breaks. When the RHS instead starts with an own-line comment, flattening changes the comment's syntactic position; a second pass then moves it after the RHS.

Validation

  • cargo test -p air_r_formatter
  • cargo test --workspace --exclude lsp
  • cargo clippy -p air_r_formatter --all-targets
  • compiled CLI two-pass checks for own-line, comment-free, and end-of-line comment cases

@msaule
msaule marked this pull request as ready for review July 22, 2026 02:10
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.

Air isn't idempotent when := expression is broken over multiple lines

1 participant