[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

llvm-svn: 326945
This commit is contained in:
Krasimir Georgiev 2018-03-07 21:30:38 +00:00
parent d8139348fb
commit 9ad7af6423
2 changed files with 8 additions and 1 deletions

View 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;
}

View 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