llvm-project/clang/unittests/Format
Krasimir Georgiev 0fad648b65 [clang-format] restore indent in conditionals when AlignOperands is DontAlign
Summary:
After D50078, we're experiencing unexpected un-indent using a style combining `AlignOperands: DontAlign` with `BreakBeforeTernaryOperators: false`, such as Google's JavaScript style:
```
% bin/clang-format -style=google ~/test.js
aaaaaaaaaaa = bbbbbbbb ? cccccccccccccccccc() :
dddddddddd             ? eeeeeeeeeeeeee :
                         fffff;
```
The issue lies with the interaction of `AlignOperands: DontAlign` and the edited code section in ContinuationIndenter.cpp, which de-dents the intent by `Style.ContinuationIndentWidth`. From [[ ac3e5c4d93/clang/include/clang/Format/Format.h (L170) | the documentation ]] of AlignOperands: DontAlign:
> The wrapped lines are indented `ContinuationIndentWidth` spaces from the start of the line.
So the de-dent effectively erases the necessary `ContinuationIndentWidth` in that case.

This patch restores the `AlignOperands: DontAlign` behavior, producing:
```
% bin/clang-format -style=google ~/test.js
aaaaaaaaaaa = bbbbbbbb ? cccccccccccccccccc() :
    dddddddddd         ? eeeeeeeeeeeeee :
                         fffff;
```

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D82199
2020-06-24 13:11:18 +02:00
..
CMakeLists.txt cmake: Add CLANG_LINK_CLANG_DYLIB option 2019-07-03 22:45:55 +00:00
CleanupTest.cpp [clang-format] NFC - clang-format the FormatTests 2020-05-02 15:42:20 +01:00
FormatTest.cpp [clang-format] restore indent in conditionals when AlignOperands is DontAlign 2020-06-24 13:11:18 +02:00
FormatTestCSharp.cpp [clang-format] Microsoft style fixes for C# properties 2020-06-09 14:50:34 +01:00
FormatTestComments.cpp [clang-format] Fix AlignConsecutive on PP blocks 2020-05-13 18:31:51 +01:00
FormatTestJS.cpp [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set 2020-05-15 16:40:31 +02:00
FormatTestJava.cpp [clang-format] NFC - clang-format the FormatTests 2020-05-02 15:42:20 +01:00
FormatTestObjC.cpp [clang-format] Fix an ObjC regression introduced with new [[likely]][[unlikely]] support in if/else clauses 2020-05-26 18:48:49 +01:00
FormatTestProto.cpp [clang-format] NFC - clang-format the FormatTests 2020-05-02 15:42:20 +01:00
FormatTestRawStrings.cpp [clang-format] NFC - clang-format the FormatTests 2020-05-02 15:42:20 +01:00
FormatTestSelective.cpp [clang-format] NFC - clang-format the FormatTests 2020-05-02 15:42:20 +01:00
FormatTestTableGen.cpp [clang-format][TableGen] Don't add spaces around items in square braces. 2019-03-01 00:12:18 +00:00
FormatTestTextProto.cpp [clang-format] NFC - clang-format the FormatTests 2020-05-02 15:42:20 +01:00
FormatTestUtils.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
NamespaceEndCommentsFixerTest.cpp [clang-format] [PR46130] When editing a file with unbalance {} the namespace comment fixer can incorrectly comment the wrong closing brace 2020-05-30 13:15:27 +01:00
SortImportsTestJS.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SortImportsTestJava.cpp [clang-format] [PR43372] - clang-format shows replacements in DOS files when no replacement is needed 2019-10-01 20:20:22 +00:00
SortIncludesTest.cpp [clang-format] NFC - clang-format the FormatTests 2020-05-02 15:42:20 +01:00
UsingDeclarationsSorterTest.cpp [clang-format] NFC - clang-format the FormatTests 2020-05-02 15:42:20 +01:00