forked from OSchip/llvm-project
[clang-format] Fix handling of TextProto comments
Differential Revision: https://reviews.llvm.org/D93163
This commit is contained in:
parent
f8079355c6
commit
374f1d81fe
|
@ -789,9 +789,14 @@ BreakableLineCommentSection::BreakableLineCommentSection(
|
||||||
Prefix[i] = "///< ";
|
Prefix[i] = "///< ";
|
||||||
else if (Prefix[i] == "//!<")
|
else if (Prefix[i] == "//!<")
|
||||||
Prefix[i] = "//!< ";
|
Prefix[i] = "//!< ";
|
||||||
else if (Prefix[i] == "#" &&
|
else if (Prefix[i] == "#")
|
||||||
Style.Language == FormatStyle::LK_TextProto)
|
|
||||||
Prefix[i] = "# ";
|
Prefix[i] = "# ";
|
||||||
|
else if (Prefix[i] == "##")
|
||||||
|
Prefix[i] = "## ";
|
||||||
|
else if (Prefix[i] == "###")
|
||||||
|
Prefix[i] = "### ";
|
||||||
|
else if (Prefix[i] == "####")
|
||||||
|
Prefix[i] = "#### ";
|
||||||
}
|
}
|
||||||
|
|
||||||
Tokens[i] = LineTok;
|
Tokens[i] = LineTok;
|
||||||
|
|
|
@ -380,25 +380,29 @@ TEST_F(FormatTestTextProto, KeepsCommentsIndentedInList) {
|
||||||
"cccccccccccccccccccccccc: 3849");
|
"cccccccccccccccccccccccc: 3849");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(FormatTestTextProto, UnderstandsHashHashComments) {
|
TEST_F(FormatTestTextProto, UnderstandsHashComments) {
|
||||||
FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
|
FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
|
||||||
Style.ColumnLimit = 60; // To make writing tests easier.
|
Style.ColumnLimit = 60; // To make writing tests easier.
|
||||||
EXPECT_EQ("aaa: 100\n"
|
EXPECT_EQ("aaa: 100\n"
|
||||||
"##this is a double-hash comment.\n"
|
"## this is a double-hash comment.\n"
|
||||||
"bb: 100\n"
|
"bb: 100\n"
|
||||||
"## another double-hash comment.\n"
|
"## another double-hash comment.\n"
|
||||||
"### a triple-hash comment\n"
|
"### a triple-hash comment\n"
|
||||||
"cc: 200\n"
|
"cc: 200\n"
|
||||||
|
"### another triple-hash comment\n"
|
||||||
"#### a quadriple-hash comment\n"
|
"#### a quadriple-hash comment\n"
|
||||||
"dd: 100\n",
|
"dd: 100\n"
|
||||||
|
"#### another quadriple-hash comment\n",
|
||||||
format("aaa: 100\n"
|
format("aaa: 100\n"
|
||||||
"##this is a double-hash comment.\n"
|
"##this is a double-hash comment.\n"
|
||||||
"bb: 100\n"
|
"bb: 100\n"
|
||||||
"## another double-hash comment.\n"
|
"## another double-hash comment.\n"
|
||||||
"### a triple-hash comment\n"
|
"###a triple-hash comment\n"
|
||||||
"cc: 200\n"
|
"cc: 200\n"
|
||||||
"#### a quadriple-hash comment\n"
|
"### another triple-hash comment\n"
|
||||||
"dd: 100\n",
|
"####a quadriple-hash comment\n"
|
||||||
|
"dd: 100\n"
|
||||||
|
"#### another quadriple-hash comment\n",
|
||||||
Style));
|
Style));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue