From 0204780a15d9d8d1bd2de6333e9abcd8ac19edf1 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 26 Feb 2015 11:46:29 +0000 Subject: [PATCH] clang-format: Make braced list formatting more consistent. Before: Aaaa aaaaaaaaaaa{ { a, // +1 indent weird. b, // trailing comma signals one per line. }, // trailing comma signals one per line. }; After: Aaaa aaaaaaaaaaa{ { a, // better!? b, // trailing comma signals one per line. }, // trailing comma signals one per line. }; Interesting that this apparently was entirely untested :-(. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230627 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/ContinuationIndenter.cpp | 1 - unittests/Format/FormatTest.cpp | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 7b36cac5dc..7c2d916ac5 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -824,7 +824,6 @@ void ContinuationIndenter::moveStatePastScopeOpener(LineState &State, ++NewIndentLevel; } else { NewIndent = State.Stack.back().LastSpace + Style.ContinuationIndentWidth; - NewIndent = std::min(State.Column + 1, NewIndent); } const FormatToken *NextNoComment = Current.getNextNonComment(); AvoidBinPacking = diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index cc27969946..9738877e45 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -5943,6 +5943,11 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) { verifyFormat("std::vector v = {1, 0 /* comment */};"); verifyFormat("Node n{1, Node{1000}, //\n" " 2};"); + verifyFormat("Aaaa aaaaaaa{\n" + " {\n" + " aaaa,\n" + " },\n" + "};"); // In combination with BinPackParameters = false. FormatStyle NoBinPacking = getLLVMStyle(); -- 2.40.0