Skip to content

Commit 5084c96

Browse files
committed
fix sumneko_1905
1 parent 7b35cb7 commit 5084c96

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

CodeService/src/Format/Analyzer/IndentationAnalyzer.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,17 @@ void IndentationAnalyzer::AnalyzeExprList(FormatState &f, LuaSyntaxNode &exprLis
160160
return;
161161
}
162162
}
163+
} else {
164+
auto symbolLine = exprList.GetPrevToken(t).GetEndLine(t);
165+
bool sameLine = true;
166+
for (auto expr: exprs) {
167+
sameLine = sameLine && expr.GetStartLine(t) == symbolLine;
168+
}
169+
if (sameLine) {
170+
return;
171+
}
163172
}
173+
164174
Indenter(exprList, t, IndentData(
165175
IndentType::Standard,
166176
f.GetStyle().continuation_indent

Test/src/FormatResult_unitest.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,4 +589,32 @@ if a then
589589
else
590590
end
591591
)"));
592+
}
593+
594+
TEST(Format, sumenko_1915) {
595+
LuaStyle s;
596+
s.indent_size = 2;
597+
EXPECT_TRUE(TestHelper::TestFormatted(
598+
R"(
599+
return nil, {
600+
sql = true,
601+
fields = true,
602+
field_names = true,
603+
extends = true,
604+
mixins = true,
605+
__index = true,
606+
admin = true
607+
}
608+
)",
609+
R"(
610+
return nil, {
611+
sql = true,
612+
fields = true,
613+
field_names = true,
614+
extends = true,
615+
mixins = true,
616+
__index = true,
617+
admin = true
618+
}
619+
)", s));
592620
}

0 commit comments

Comments
 (0)