Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormatWriter: accumulate align shift correctly #3615

Merged
merged 2 commits into from
Aug 18, 2023

Conversation

kitbellew
Copy link
Collaborator

Alignment logic accumulates alignment shift for matching lines, with the assumption that the extra space will definitely be added.

However, we don't add extra spaces to no-split cases, instead attempting to delay them until the next token... but if the next token is also a no-split, then the extra alignment space is lost, leading to incorrect formatting.

One such example is ( which typically has no spaces before or after.

Helps with #3614.

Alignment logic accumulates alignment shift for matching lines, with the
assumption that the extra space will definitely be added.

However, we don't add extra spaces to no-split cases, instead attempting
to delay them until the next token... but if the next token is also a
no-split, then the extra alignment space is lost, leading to incorrect
formatting.

One such example is `(` which typically has no spaces before or after.
@kitbellew kitbellew requested a review from tgodzik August 18, 2023 15:54
@kitbellew kitbellew mentioned this pull request Aug 18, 2023
@kitbellew kitbellew merged commit 5015f57 into scalameta:master Aug 18, 2023
8 checks passed
@kitbellew kitbellew deleted the 3614 branch August 18, 2023 18:05
srowen pushed a commit to apache/spark that referenced this pull request Sep 2, 2023
### What changes were proposed in this pull request?
The pr aims to upgrade `scalafmt` from 3.7.5 to 3.7.13.

### Why are the changes needed?
1.The newest version include some bug fixed, eg:
- FormatWriter: accumulate align shift correctly (scalameta/scalafmt#3615)
- Indents: ignore fewerBraces if indentation is 1 (scalameta/scalafmt#3592)
- RemoveScala3OptionalBraces: handle infix on rbrace (scalameta/scalafmt#3576)

2.The full release notes:
https://github.com/scalameta/scalafmt/releases/tag/v3.7.13
https://github.com/scalameta/scalafmt/releases/tag/v3.7.12
https://github.com/scalameta/scalafmt/releases/tag/v3.7.11
https://github.com/scalameta/scalafmt/releases/tag/v3.7.10
https://github.com/scalameta/scalafmt/releases/tag/v3.7.9
https://github.com/scalameta/scalafmt/releases/tag/v3.7.8
https://github.com/scalameta/scalafmt/releases/tag/v3.7.7
https://github.com/scalameta/scalafmt/releases/tag/v3.7.6

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Pass GA.

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #42764 from panbingkun/SPARK-45043.

Authored-by: panbingkun <pbk1982@gmail.com>
Signed-off-by: Sean Owen <srowen@gmail.com>
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.

2 participants