[PATCH] D50699: [clang-format] fix PR38525 - Extraneous continuation indent spaces with BreakBeforeBinaryOperators set to All
Jonas Toth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 24 10:15:33 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340623: [clang-format] fix PR38525 - Extraneous continuation indent spaces with… (authored by JonasToth, committed by ).
Repository:
rC Clang
https://reviews.llvm.org/D50699
Files:
lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTest.cpp
Index: lib/Format/ContinuationIndenter.cpp
===================================================================
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -700,7 +700,8 @@
// Indent relative to the RHS of the expression unless this is a simple
// assignment without binary expression on the RHS. Also indent relative to
// unary operators and the colons of constructor initializers.
- State.Stack.back().LastSpace = State.Column;
+ if (Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None)
+ State.Stack.back().LastSpace = State.Column;
} else if (Previous.is(TT_InheritanceColon)) {
State.Stack.back().Indent = State.Column;
State.Stack.back().LastSpace = State.Column;
Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -3375,6 +3375,18 @@
" = bbbbbbbbbbbbbbbbb\n"
" >> aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaa);",
Style);
+
+ Style.ColumnLimit = 80;
+ Style.IndentWidth = 4;
+ Style.TabWidth = 4;
+ Style.UseTab = FormatStyle::UT_Always;
+ Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+ Style.AlignOperands = false;
+ EXPECT_EQ("return someVeryVeryLongConditionThatBarelyFitsOnALine\n"
+ "\t&& (someOtherLongishConditionPart1\n"
+ "\t\t|| someOtherEvenLongerNestedConditionPart2);",
+ format("return someVeryVeryLongConditionThatBarelyFitsOnALine && (someOtherLongishConditionPart1 || someOtherEvenLongerNestedConditionPart2);",
+ Style));
}
TEST_F(FormatTest, EnforcedOperatorWraps) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50699.162409.patch
Type: text/x-patch
Size: 1737 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180824/db2f6259/attachment.bin>
More information about the cfe-commits
mailing list