Description
Bugzilla Link | 27678 |
Version | unspecified |
OS | Windows NT |
Reporter | LLVM Bugzilla Contributor |
Extended Description
If I write a sample line like:
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.
My current config:
BasedOnStyle: LLVM
Language: Cpp
AlignAfterOpenBracket: DontAlign
BreakBeforeBraces: Allman
IndentWidth: 4
ContinuationIndentWidth: 2
ColumnLimit: 80
AlignOperands: false
BreakBeforeBinaryOperators: false