Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CodeFormatCore/src/Format/Analyzer/LineBreakAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,15 @@ void LineBreakAnalyzer::ComplexAnalyze(FormatState &f, const LuaSyntaxTree &t) {

} else {
switch (stmt.GetTokenKind(t)) {
case TK_SHORT_COMMENT:
case TK_LONG_COMMENT:
{
auto nextToken = stmt.GetNextToken(t).GetTokenKind(t);
if (nextToken == TK_SHORT_COMMENT) {
break;
}
// Fall through
}
case TK_SHORT_COMMENT:
case TK_SHEBANG: {
BreakAfter(stmt, t, style.line_space_after_comment);
break;
Expand Down
28 changes: 28 additions & 0 deletions Test/src/FormatResult_unitest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,3 +1147,31 @@ only_latin = {
}
)", style));
}

TEST(Format, issue_170) {
EXPECT_TRUE(TestHelper::TestFormatted(
R"(
--[[]]
)",
R"(
--[[]]
)"));
EXPECT_TRUE(TestHelper::TestFormatted(
R"(
--[[]]--
)",
R"(
--[[]] --
)"));
EXPECT_TRUE(TestHelper::TestFormatted(
R"(
--[[-----------

]]-------------
)",
R"(
--[[-----------

]] -------------
)"));
}