-
Notifications
You must be signed in to change notification settings - Fork 16
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
Classic if/then/else formatting. #12
Comments
I think you can accomplish this with a list of 2 elements, using
(aaaaaa, bbbbbb)
|
I was having similar problems implementing if/else if/else breaks since if you use Labels to implement it will break in the wrong order, as per below:
By changing it to a list and manually adding splitting
@jordwalke it won't quite solve the problem since half the breaks still happen one level down, but it's closer :/ |
Can you show the case where "half the breaks still happen one level down"? |
The list inserts the newline for the trailing "}" whereas the statement list is separated onto a newline via the Label within the list, like so:
Thinking about this more we could potentially remove the
I haven't tried it but in theory it could work :/ |
The only problem with the last suggestion (I think) is that you indent even if the |
I guess it depends on how bad you want to allow people to configure the formatter to output: let x = if (something) {thenThis} else {thenThat}; Since in ES6, ifs aren't expressions, it's probably much less important to support the non-breaking if/else scenario. |
Not sure if this would work but may be able to use |
Potentially should work if you output like this (apart from the inner indentation):
|
Yes, that sounds wonderful. We were discussing the same proposal for trailing commas. It would perhaps make a nice PR to It would also be cool if we could have something even more advanced than switching between two atoms (two complete |
This is one pattern that I've had a hard time figuring out how to accomplish with the formatting primitives in Eeasy_format:
Where if for any reason the "if braces" had broken, then the "else braces" should also break.
The text was updated successfully, but these errors were encountered: