[clang-format] Fix a bug in ReflowComments: Always (#146202)
Fixes #39150
This commit is contained in:
@@ -158,8 +158,7 @@ getCommentSplit(StringRef Text, unsigned ContentStartColumn,
|
||||
return BreakableToken::Split(StringRef::npos, 0);
|
||||
StringRef BeforeCut = Text.substr(0, SpaceOffset).rtrim(Blanks);
|
||||
StringRef AfterCut = Text.substr(SpaceOffset);
|
||||
// Don't trim the leading blanks if it would create a */ after the break.
|
||||
if (!DecorationEndsWithStar || AfterCut.size() <= 1 || AfterCut[1] != '/')
|
||||
if (!DecorationEndsWithStar)
|
||||
AfterCut = AfterCut.ltrim(Blanks);
|
||||
return BreakableToken::Split(BeforeCut.size(),
|
||||
AfterCut.begin() - BeforeCut.end());
|
||||
|
||||
@@ -2486,7 +2486,7 @@ TEST_F(FormatTestComments, BlockComments) {
|
||||
EXPECT_EQ("/*\n"
|
||||
"**\n"
|
||||
"* aaaaaa\n"
|
||||
"*aaaaaa\n"
|
||||
"* aaaaaa\n"
|
||||
"*/",
|
||||
format("/*\n"
|
||||
"**\n"
|
||||
|
||||
Reference in New Issue
Block a user