fix: hug lambdas without blocks#653
Conversation
|
|
||
| if (findDeepElementInPartsArray(lambdaParameterList, ",")) { | ||
| const separator = params?.shouldBreak === false ? "" : softline; | ||
| const content = putIntoBraces( |
There was a problem hiding this comment.
I think that there is some logic handling comments around braces in the putIntoBraces function: does it still works well if you remove the putIntoBraces method ?
There was a problem hiding this comment.
You're very right! This ended up sending me down quite a bit of a rabbit hole.
I realized that, because of the way putIntoBraces removes comments and puts them directly into the Doc it returns (rather than moving them to another token/node), it meant that certain code paths in which I leveraged the conditionalGroup function (introduced in #632) could result in comments being removed from the code entirely (😱).
I believe that I have now fixed that problem, and have added a bunch of tests for comments around methods and lambdas to ensure I handled all those cases properly.
c6f18b9 to
4aab0b1
Compare
|
@clementdessoude Apologies for the ping, but just wanted to check in to ask if you could take another look at this, whenever you have the time. Thanks in advance! |
|
Hello @jtkiesel ! No worry for the ping, it is totally normal. Would you be able to have a chat (through mail/twitter/linkedin/any media you want) ? I tried to contact you via linkedin a few weeks ago to discuss about the project, but you may have missed it :) |
What changed with this PR:
Argument "hugging" is now aligned much more closely with Prettier JavaScript. Specifically, lambdas without blocks are "huggable" again.
Example
Input
Output
Relative issues or prs:
Closes #650