]> granicus.if.org Git - clang/commitdiff
[clang-format] Break consecutive string literals in text protos
authorKrasimir Georgiev <krasimir@google.com>
Wed, 7 Mar 2018 21:30:38 +0000 (21:30 +0000)
committerKrasimir Georgiev <krasimir@google.com>
Wed, 7 Mar 2018 21:30:38 +0000 (21:30 +0000)
Summary:
This patch fixes a bug where consecutive string literals in text protos were
put on the same line.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D44204

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326945 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestTextProto.cpp

index 013a77b4c59efd6bf210f25b47365144607626a4..97a201d267e8eb039ff369b60be63729dcb2a52d 100644 (file)
@@ -2717,7 +2717,8 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
       return true;
   } else if (Style.Language == FormatStyle::LK_Cpp ||
              Style.Language == FormatStyle::LK_ObjC ||
-             Style.Language == FormatStyle::LK_Proto) {
+             Style.Language == FormatStyle::LK_Proto ||
+             Style.Language == FormatStyle::LK_TextProto) {
     if (Left.isStringLiteral() && Right.isStringLiteral())
       return true;
   }
index 1102055ea372b9933ff4d1f2d6ea03a0f407aa75..39a2e71cbbd13168322e4c52a2ad9b687fc80b0c 100644 (file)
@@ -452,5 +452,11 @@ TEST_F(FormatTestTextProto, AcceptsOperatorAsKey) {
                "  >\n"
                ">");
 }
+
+TEST_F(FormatTestTextProto, BreaksConsecutiveStringLiterals) {
+  verifyFormat("ala: \"str1\"\n"
+               "     \"str2\"\n");
+}
+
 } // end namespace tooling
 } // end namespace clang