You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (strcmp("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"))
b=1;
and tell clang-format to format it; when I have "IndentWidth: 4" and "ContinuationIndentWidth: 2", I get:
if (strcmp("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"))
b = 1;
Since my Continuation Indent Width is 2, I should get:
if (strcmp("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"))
b = 1;
Note that if I simply remove the "if" and the following space, and put a semicolon at the end of the line, the expected indentation is produced. It is evidently keying off this being a conditional, since this statement is formatted thusly:
a = strcmp("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
? 1
: 0;
I understand if some users feel that the way it currently operates is more readable; but others like me may prefer to have the extra room on the line, in what not uncommonly, long if conditions. If on the other hand, this special exception is to be made for the if statement alone (or whatever other statements are currently special cases like this), I propose you create a new continuation indent setting to override it, e.g.: "ConditionalContinuationIndentWidth: 2". I suppose this bug is being exposed because I am not aligning my function arguments on the next line - opting again for more room on the line.
I'm also confused by this behaviour. I don't want to fight the tool but it seems inconsistent as it indents differently based on a function's open paren inside a control statement. See A vs. B below.
I don't understand the reasoning behind why A is formatted differently than B. I would find it more intuitive if either all control statements indent wrapped lines like A with 6 spaces:
// E:
if (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb &&
(cccccccccccccccccccccccccccccccccc || dddddddddddddddddddddddddddddddddd))
b = 1;
Or like the above B case:
// B:
if (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb &&
(cccccccccccccccccccccccccccccccccc || dddddddddddddddddddddddddddddddddd))
b = 1;
Given the choice, I'd like it to respect the AlignAfterOpenBracket + ContinuationIndentWidth setting, but consistency is most important to me.
I'd also be happy with reasoning behind the choice if it was made consciously. I'm all for learning something new :)
Extended Description
If I write a sample line like:
and tell clang-format to format it; when I have "IndentWidth: 4" and "ContinuationIndentWidth: 2", I get:
Since my Continuation Indent Width is 2, I should get:
Note that if I simply remove the "if" and the following space, and put a semicolon at the end of the line, the expected indentation is produced. It is evidently keying off this being a conditional, since this statement is formatted thusly:
I understand if some users feel that the way it currently operates is more readable; but others like me may prefer to have the extra room on the line, in what not uncommonly, long if conditions. If on the other hand, this special exception is to be made for the if statement alone (or whatever other statements are currently special cases like this), I propose you create a new continuation indent setting to override it, e.g.: "ConditionalContinuationIndentWidth: 2". I suppose this bug is being exposed because I am not aligning my function arguments on the next line - opting again for more room on the line.
My current config:
BasedOnStyle: LLVM
Language: Cpp
AlignAfterOpenBracket: DontAlign
BreakBeforeBraces: Allman
IndentWidth: 4
ContinuationIndentWidth: 2
ColumnLimit: 80
AlignOperands: false
BreakBeforeBinaryOperators: false
The text was updated successfully, but these errors were encountered: