-
Notifications
You must be signed in to change notification settings - Fork 659
fix(formatter): Stable member chain printing #2582
Conversation
This PR simplifies the member printing logic to make sure its output is stable. This results in a small regression ``` Before: **File Based Average Prettier Similarity**: 69.29% **Line Based Average Prettier Similarity**: 64.28% After: **File Based Average Prettier Similarity**: 69.13% **Line Based Average Prettier Similarity**: 64.06% ``` But unblocks my work on refactoring the printer behaviour (which seems to trigger this now a lot), and #2458
084f8c5
to
03cc0d5
Compare
Deploying with Cloudflare Pages
|
Parser conformance results on ubuntu-latestjs/262
jsx/babel
ts/babel
ts/microsoft
|
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.
I does result in quite a few regressions but I guess that's fine as the intent is to go back to the chain printing later on and fully align it with Prettier when we have the appropriate IR to do so
@@ -132,53 +103,16 @@ impl<'f> Groups<'f> { | |||
/// Format groups on multiple lines | |||
pub fn into_joined_hard_line_groups(self) -> FormatElement { | |||
let formatted_groups = self.into_formatted_groups(); | |||
join_elements(hard_line_break(), formatted_groups) | |||
concat_elements(formatted_groups) |
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.
This method is now doing the same thing as into_format_elements
, is there any point in keeping it ?
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.
I reverted this change with the added benefit that there are now fewer regressions (overall even an increase in prettier compatibility)
crates/rome_js_formatter/tests/specs/prettier/js/binary-expressions/arrow.js.snap
Outdated
Show resolved
Hide resolved
cf41f8f
to
f3fb11a
Compare
@cpojer You should be able to land your PR after this :) I think it's improving our new metric by about 1%! |
Yeah, unfortunately. But it's sometimes necessary to go a few steps back to be able to move forward again. I think this is one such situation (I still have to fight with some other unstable results but at least fewer of them) |
I am not sure if this was the correct way to go. I hope it is. It seems that lot of logic taken from prettier was removed. |
I agree that this hasn't been ideal but it was, in my view necessary, to make progress on changing the underlying printer architecture without being stuck for days (It still took me 1.5 weeks). It should be easier to re-add this logic now, that the printer works the same as prettier. Something I noticed is that we often form groups in the exact opposite order than prettier. For example, prettier groups |
This PR simplifies the member printing logic to make sure its output is stable.
Interestingly, this is slightly improving the prettier compatibility
But unblocks my work on refactoring the printer behaviour (which seems to trigger this now a lot), and #2458 . The work on improving the formatting is tracked in #2421
Test Plan
I rebased #2458 (need to find a way to push this change) and the tests now pass.