summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp16
-rw-r--r--clang/unittests/Format/FormatTestTextProto.cpp4
2 files changed, 13 insertions, 7 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index ca648dc1ec8..19f2ddae6cf 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -462,13 +462,15 @@ private:
FormatToken *Previous = CurrentToken->getPreviousNonComment();
if (Previous->is(TT_JsTypeOptionalQuestion))
Previous = Previous->getPreviousNonComment();
- if (((CurrentToken->is(tok::colon) &&
- (!Contexts.back().ColonIsDictLiteral || !Style.isCpp())) ||
- Style.Language == FormatStyle::LK_Proto ||
- Style.Language == FormatStyle::LK_TextProto) &&
- (Previous->Tok.getIdentifierInfo() ||
- Previous->is(tok::string_literal)))
- Previous->Type = TT_SelectorName;
+ if ((CurrentToken->is(tok::colon) &&
+ (!Contexts.back().ColonIsDictLiteral || !Style.isCpp())) ||
+ Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto) {
+ Left->Type = TT_DictLiteral;
+ if (Previous->Tok.getIdentifierInfo() ||
+ Previous->is(tok::string_literal))
+ Previous->Type = TT_SelectorName;
+ }
if (CurrentToken->is(tok::colon) ||
Style.Language == FormatStyle::LK_JavaScript)
Left->Type = TT_DictLiteral;
diff --git a/clang/unittests/Format/FormatTestTextProto.cpp b/clang/unittests/Format/FormatTestTextProto.cpp
index 82da8737a37..26de5c9d106 100644
--- a/clang/unittests/Format/FormatTestTextProto.cpp
+++ b/clang/unittests/Format/FormatTestTextProto.cpp
@@ -289,6 +289,10 @@ TEST_F(FormatTestTextProto, SupportsAngleBracketMessageFields) {
" headheadheadheadheadhead_id: 1\n"
" product_data <product {1}>\n"
">");
+
+ verifyFormat("dcccwrnfioeruvginerurneitinfo {\n"
+ " exte3nsionrnfvui {key: value}\n"
+ "}");
}
TEST_F(FormatTestTextProto, DiscardsUnbreakableTailIfCanBreakAfter) {
OpenPOWER on IntegriCloud