I would like to have this:
if (!enabled)
{
return;
}
turned to this:
if (!enabled) { return; }
(In other words, I want short if-statements on a single line but keep the {}
around them)
Currently I'm using the following configuration:
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: true
AllowShortBlocksOnASingleLine: true
BreakBeforeBraces: Allman
However, the output I'm getting is:
if (!enabled)
{
return;
}
Is the above formatting possible to accomplish with clang-format?
Removing
BreakBeforeBraces: Allman
Seems to do what you want (for me). I'm using SVN clang though. Although you probably wanted it there for a reason.
According to the clang-format docs, the AllowShortBlocksOnASingleLine
should do exactly what you want (regardless of brace style). This might be a bug in clang-format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With