From 343fc1bef188c90a44d7933eb17fb86996ebc09a Mon Sep 17 00:00:00 2001 From: Daniel Jasper <djasper@google.com> Date: Wed, 29 Jan 2014 18:43:40 +0000 Subject: [PATCH] clang-format: Fix formatting of custom proto options. Before: repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = { aaaaaaaaaaaaaaaaa : AAAAAAAA }]; After: repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaaa : AAAAAAAA}]; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200405 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 2 +- unittests/Format/FormatTestProto.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 6e82b19148c..a0edae51a72 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1469,7 +1469,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, // deliberate choice and might have aligned the contents of the string // literal accordingly. Thus, we try keep existing line breaks. return Right.NewlinesBefore > 0; - } else if (Right.Previous->is(tok::l_brace) && + } else if (Right.Previous->is(tok::l_brace) && Right.NestingLevel == 1 && Style.Language == FormatStyle::LK_Proto) { // Don't enums onto single lines in protocol buffers. return true; diff --git a/unittests/Format/FormatTestProto.cpp b/unittests/Format/FormatTestProto.cpp index 6304d9688fd..443c3e10159 100644 --- a/unittests/Format/FormatTestProto.cpp +++ b/unittests/Format/FormatTestProto.cpp @@ -80,6 +80,8 @@ TEST_F(FormatTestProto, MessageFieldAttributes) { " deprecated = true];"); verifyFormat("optional LongMessageType long_proto_field = 1\n" " [default = REALLY_REALLY_LONG_CONSTANT_VALUE];"); + verifyFormat("repeated double value = 1\n" + " [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaaa : AAAAAAAA}];"); } TEST_F(FormatTestProto, FormatsOptions) { -- GitLab