This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 660
fix(rome_js_formatter): regression of call arguments #2812
Merged
Merged
Conversation
This file contains 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
Deploying with Cloudflare Pages
|
denbezrukov
reviewed
Jul 4, 2022
leops
reviewed
Jul 4, 2022
write!(will_break_buffer, [element]).ok(); | ||
will_break_buffer.will_break() | ||
}); | ||
let any_breaks = arguments_break.any(|will_break| will_break); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly calling .any
will mutate the arguments_break
iterator in place, so all the iterators items consumed to initialize any_breaks
will not be processed by the next call to .any
to initialize an_argument_breaks
, is this really what's intended here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's really a good catch, and I was wondering why I could not replicate a reformat issue that I was encountering some time ago.
leops
reviewed
Jul 4, 2022
leops
approved these changes
Jul 4, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
This PR fixed #2720
The new logic checks if any arguments breaks and if so, it does a custom printing.
Doing so, it triggered a regression of the new code that we didn't see before:
This snippet:
Would be formatted
Note the space added before the first
(
. This regression is caused by a bug inside the functionwrite_space_between_comment_and_token
, which triggers a false positive condition and it adds a space before the token.I will have to look into it later. In order to avoid to commit wrong code, I changed the snippet that was causing the false positive. Tracked in #2814
Another regression that is triggered by our printer is already tracked in #2815 . This issue is caused by how
best_fitting!
prints the second alternative.I would like to shut down this reformat issue, because the regression that is fixed in this PR is actually more important then the format issue, I think.
Test Plan
cargo test
and checked that the regression is not fixedPR
File Based Average Prettier Similarity: 77.44%
Line Based Average Prettier Similarity: 72.72%
main
File Based Average Prettier Similarity: 77.33%
Line Based Average Prettier Similarity: 72.61%