No wrapping option for if() statement in code style
For some reason there is no wrapping selection after the "if() statement" in code style settings?
I expected a selection like that in the "for()/foreach() statements...is this a bug or intentional?
Please sign in to leave a comment.
Yeah, that doesn't look right. Would an IDE restart help?
Are you on linux? If you are - please try to reinstall IDE into an empty directory.
Lastly check if the issue persists after disabling all custom plugins at Settings | Plugins > Installed > `#custom` + IDE restart.
Hi,
Did you find solution to this. I've just found that I'm missing this option too.
I have disabled all downloaded plugins but still no success.
Checked this again - my reply above is incorrect. There's no "wrapping" dropdown menu for "'if()' statement" historically: neither in old IDE version nor now.
But I believe existing options are sufficient to configure the desired code wrapping. If not - could you please attach a code example that would illustrate "desired" and "actual" formatting?
Having wrapping option for if () statement would be useful as for other control statements.
For example when if () condition is long.
I've hope that below example is sufficient:
Thanks for the example.
You have binary expressions here so you need to set "Chop down if long" for Binary expressions instead. Also set the "Operation sign on next line" checkbox there.
Thanks for the info, unfortunately this causes all binary expressions to change and if statements don't look as I would wish to.
Yes, this unfortunately can't be automatically formatted per your desire.
I'd suggest to enable "Line breaks" checkbox for "Keep when reformatting" & this:
Then place line breaks manually as needed.
They won't be changed on a reformat afterward.
I believe it should be relatively easy to add wrapping options for "IF".
First chop / wrap by "&&" and "||" operators and if it's still long then split by the rest of binary operators.
This would give more flexibility and it wouldn't be affected by other formatting options which my not be relevant for IF statements.
Is this something what you would consider adding to PhpStorm / IntelliJ ?
Thanks for the info. Could you please share it (your example & proposal) in a comment to a corresponding feature request? Here's a link to it: https://youtrack.jetbrains.com/issue/WI-30324
Hi Dmitry,
is there any quick solution for the Reformater, to enforce wished formatting rules? I also would need something like this:
You can specify required formatting rules in Settings | Editor | Code Style | JavaScript window. You can go to the 'Wrappings and Braces' tab.
From what I gather, you want to add line breaks in binary expressions so conditions in 'if' statements are displayed on different lines. If so, you can select 'Wrap Always' for binary expressions. Does this meet your requirements?