Skip to content

Commit 7bee434

Browse files
committed
fix #93
1 parent f9448d8 commit 7bee434

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

CodeService/src/Format/Analyzer/IndentationAnalyzer.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,6 @@ void IndentationAnalyzer::Analyze(FormatState &f, const LuaSyntaxTree &t) {
5858
if (syntaxNode.GetChildToken('(', t).IsToken(t)) {
5959
auto exprList = syntaxNode.GetChildSyntaxNode(NodeKind::ExpressionList, t);
6060
if (exprList.IsNode(t)) {
61-
// for (auto expr: exprList.GetChildren(t)) {
62-
// if (f.GetStyle().function_call_use_continuation_indent) {
63-
// Indenter(expr, t, IndentData(
64-
// IndentType::WhenLineBreak,
65-
// f.GetStyle().continuation_indent
66-
// ));
67-
// } else {
68-
// Indenter(expr, t, IndentData(
69-
// IndentType::WhenLineBreak,
70-
// f.GetStyle().indent_style == IndentStyle::Space ?
71-
// f.GetStyle().indent_size : f.GetStyle().tab_width
72-
// ));
73-
// }
74-
// }
7561
AnalyzeCallExprList(f, exprList, t);
7662
}
7763
}
@@ -296,7 +282,7 @@ bool IndentationAnalyzer::IsExprShouldIndent(LuaSyntaxNode &expr, const LuaSynta
296282
case LuaSyntaxNodeKind::SuffixedExpression: {
297283
auto subExprs = expr.GetChildSyntaxNodes(LuaSyntaxMultiKind::Expression, t);
298284
for (auto subExpr: subExprs) {
299-
if (subExpr.GetStartLine(t) != symbolLine) {
285+
if (IsExprShouldIndent(subExpr, t)) {
300286
return true;
301287
}
302288
}

Test/src/FormatResult_unitest.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,4 +762,36 @@ Garbage = {
762762
}
763763
}
764764
)"));
765+
}
766+
767+
TEST(Format, codestyle_93) {
768+
LuaStyle s;
769+
s.indent_size = 2;
770+
EXPECT_TRUE(TestHelper::TestFormatted(
771+
R"(
772+
local context = {
773+
form_field_token = utils.trunk(form_field_token, 2):map(function(e)
774+
local form_item_token, widget = e[1], e[2]
775+
return format(form_item_token, widget)
776+
end):join('\n'),
777+
}
778+
local a = aaa.p(function()
779+
end):okok()
780+
local a2 = aaa.p(function()
781+
end)
782+
:okok()
783+
)",
784+
R"(
785+
local context = {
786+
form_field_token = utils.trunk(form_field_token, 2):map(function(e)
787+
local form_item_token, widget = e[1], e[2]
788+
return format(form_item_token, widget)
789+
end):join('\n'),
790+
}
791+
local a = aaa.p(function()
792+
end):okok()
793+
local a2 = aaa.p(function()
794+
end)
795+
:okok()
796+
)", s));
765797
}

include/CodeService/Config/LuaStyle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,6 @@ class LuaStyle {
145145

146146
// not implement now
147147
bool leading_comma_style = false;
148+
149+
bool table_list_special_continue_indent = true;
148150
};

0 commit comments

Comments
 (0)