[clang-format] PR48539 ReflowComments breaks Qt translation comments

https://bugs.llvm.org/show_bug.cgi?id=48539

Add support for Qt Translator Comments to reflow

When reflown and a part of the comments are added on a new line, it should repeat these extra characters as part of the comment token.

Reviewed By: curdeius, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D93490
This commit is contained in:
mydeveloperday 2020-12-23 14:44:31 +00:00
parent 5426b2f9ed
commit 031743cb5b
2 changed files with 8 additions and 2 deletions

View File

@ -41,8 +41,8 @@ static bool IsBlank(char C) {
static StringRef getLineCommentIndentPrefix(StringRef Comment,
const FormatStyle &Style) {
static const char *const KnownCStylePrefixes[] = {"///<", "//!<", "///", "//",
"//!"};
static const char *const KnownCStylePrefixes[] = {"///<", "//!<", "///",
"//", "//!", "//:"};
static const char *const KnownTextProtoPrefixes[] = {"//", "#", "##", "###",
"####"};
ArrayRef<const char *> KnownPrefixes(KnownCStylePrefixes);

View File

@ -702,6 +702,12 @@ TEST_F(FormatTestComments, SplitsLongCxxComments) {
" // long 1 2 3 4 5 6\n"
"}",
getLLVMStyleWithColumns(20)));
EXPECT_EQ("//: A comment that\n"
"//: doesn't fit on\n"
"//: one line",
format("//: A comment that doesn't fit on one line",
getLLVMStyleWithColumns(20)));
}
TEST_F(FormatTestComments, PreservesHangingIndentInCxxComments) {