Skip to content

Commit 3d4c7a6

Browse files
committed
修复缩进问题
1 parent 6751ecd commit 3d4c7a6

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

CodeService/src/Format/Analyzer/IndentationAnalyzer.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,13 @@ void IndentationAnalyzer::AnalyzeExprList(FormatState &f, LuaSyntaxNode &exprLis
148148
return;
149149
}
150150
if (syntaxKind == LuaSyntaxNodeKind::SuffixedExpression) {
151-
auto callExpr = expr.GetChildSyntaxNode(LuaSyntaxNodeKind::CallExpression, t);
152-
if (callExpr.IsNode(t)
153-
&& (callExpr.GetPrevToken(t).GetStartLine(t) == expr.GetPrevToken(t).GetStartLine(t))) {
151+
auto subExprs = expr.GetChildSyntaxNodes(LuaSyntaxMultiKind::Expression, t);
152+
auto symbolLine = expr.GetPrevToken(t).GetEndLine(t);
153+
bool sameLine = true;
154+
for (auto subExpr: subExprs) {
155+
sameLine = sameLine && subExpr.GetStartLine(t) == symbolLine;
156+
}
157+
if (sameLine) {
154158
return;
155159
}
156160
}

Test2/src/FormatTest2.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
int main() {
99
std::string buffer = R"(
10-
local t = a.b.c.setmetatable(f, function ()
11-
end)
10+
local t = switch(a)
11+
:case(function()
12+
end)
13+
1214
)";
1315

1416
auto file = std::make_shared<LuaFile>(std::move(buffer));

0 commit comments

Comments
 (0)