From: Krasimir Georgiev Date: Wed, 7 Mar 2018 21:30:38 +0000 (+0000) Subject: [clang-format] Break consecutive string literals in text protos X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=48e9e5d6ad65f3248969f1941924c4cbf5c13f84;p=clang [clang-format] Break consecutive string literals in text protos 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 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 013a77b4c5..97a201d267 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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; } diff --git a/unittests/Format/FormatTestTextProto.cpp b/unittests/Format/FormatTestTextProto.cpp index 1102055ea3..39a2e71cbb 100644 --- a/unittests/Format/FormatTestTextProto.cpp +++ b/unittests/Format/FormatTestTextProto.cpp @@ -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