[clang-format] Fix a bug in ReflowComments: Always (#146202)

Fixes #39150
This commit is contained in:
Owen Pan
2025-06-28 15:23:00 -07:00
committed by GitHub
parent d2e8e55e02
commit f771d08a24
2 changed files with 2 additions and 3 deletions

View File

@@ -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());

View File

@@ -2486,7 +2486,7 @@ TEST_F(FormatTestComments, BlockComments) {
EXPECT_EQ("/*\n"
"**\n"
"* aaaaaa\n"
"*aaaaaa\n"
"* aaaaaa\n"
"*/",
format("/*\n"
"**\n"