Skip to content

Commit 031743c

Browse files
[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
1 parent 5426b2f commit 031743c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

clang/lib/Format/BreakableToken.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ static bool IsBlank(char C) {
4141

4242
static StringRef getLineCommentIndentPrefix(StringRef Comment,
4343
const FormatStyle &Style) {
44-
static const char *const KnownCStylePrefixes[] = {"///<", "//!<", "///", "//",
45-
"//!"};
44+
static const char *const KnownCStylePrefixes[] = {"///<", "//!<", "///",
45+
"//", "//!", "//:"};
4646
static const char *const KnownTextProtoPrefixes[] = {"//", "#", "##", "###",
4747
"####"};
4848
ArrayRef<const char *> KnownPrefixes(KnownCStylePrefixes);

clang/unittests/Format/FormatTestComments.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,12 @@ TEST_F(FormatTestComments, SplitsLongCxxComments) {
702702
" // long 1 2 3 4 5 6\n"
703703
"}",
704704
getLLVMStyleWithColumns(20)));
705+
706+
EXPECT_EQ("//: A comment that\n"
707+
"//: doesn't fit on\n"
708+
"//: one line",
709+
format("//: A comment that doesn't fit on one line",
710+
getLLVMStyleWithColumns(20)));
705711
}
706712

707713
TEST_F(FormatTestComments, PreservesHangingIndentInCxxComments) {

0 commit comments

Comments
 (0)