When using --style=1tbs --indent=spaces=2 --break-elseifs --add-brackets --mode=cs
to format the following code:
if (cond1) {
code1
} else if (cond2) {
code2
} else if (cond3) {
code3
}
the resulting code is:
if (cond1) {
code1
} else
if (cond2) {
code2
} else
if (cond3) {
code3
}
but... I would expect it to be:
if (cond1) {
code1
} else {
if (cond2) {
code2
} else {
if (cond3) {
code3
}
}
}
I couldnt' find any combination of settings that got me to that result, so I'm assuming this is a bug.
If this is not a bug, can someone explain how to get the enclosing bodies for each else.
Adding brackets for each else can change the results of the statement.
For this reason it isn't done.
Well if the brackets are not present, then it's not 1TBS.
Can you provide an exampe of when breaking an elseif into an else + if with appropriate bracketing for the else body, and the if body, would change the results? As I don't see how this is possible (pending the brackets are put in place properly).
Are you saying it's not possible to programmitcally add the brackets properly?
Last edit: Xorcist 2016-04-19