Skip to content

Commit af23a86

Browse files
committed
修改函数调用时参数的排版原则
1 parent 29a69ce commit af23a86

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

CodeService/src/FormatElement/CallArgsListLayoutElement.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void CallArgsListLayoutElement::SerializeSubExpression(SerializeContext& ctx, st
100100
auto& children = parent->GetChildren();
101101
auto it = children.begin();
102102

103-
if (topLevelSubexpression && _hasLineBreak && IsLastArg(parent))
103+
if (topLevelSubexpression && _hasLineBreak && IsLastArg(parent) && ctx.GetCharacterCount() != 0)
104104
{
105105
auto expression = *it;
106106
if (expression->Is(FormatElementType::ExpressionElement))
@@ -155,7 +155,7 @@ void CallArgsListLayoutElement::DiagnoseSubExpression(DiagnosisContext& ctx, std
155155
}
156156
auto it = children.begin();
157157

158-
if (topLevelSubexpression && _hasLineBreak && IsLastArg(parent))
158+
if (topLevelSubexpression && _hasLineBreak && IsLastArg(parent) && ctx.GetCharacterCount() != 0)
159159
{
160160
auto expression = *it;
161161
if (expression->Is(FormatElementType::ExpressionElement))

Test/test_script/format_text/wait_format/expression.lua

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,39 @@ local t = TEST
5555
[[
5656
5757
]]
58+
59+
p
60+
{
61+
a = 1321
62+
}
63+
{
64+
afajogfj = 131
65+
}
66+
67+
P2(AA, BBB, function ()
68+
69+
end)
70+
71+
P3(aa ..
72+
bbb , function()
73+
74+
end)
75+
76+
P4(eee
77+
.. eee + cccc, {
78+
aa = 123
79+
})
80+
81+
p5(hhhh
82+
+ joijfoiji,
83+
{
84+
ok = main
85+
})
86+
87+
p6(haode
88+
+ jjjjj,
89+
function ()
90+
91+
end)
92+
93+

Test/test_script/format_text/wait_format_should_be/expression.lua

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,37 @@ local t = TEST
5555
[[
5656
5757
]]
58+
59+
p
60+
{
61+
a = 1321
62+
}
63+
{
64+
afajogfj = 131
65+
}
66+
67+
P2(AA, BBB, function()
68+
69+
end)
70+
71+
P3(aa ..
72+
bbb, function()
73+
74+
end)
75+
76+
P4(eee
77+
.. eee + cccc, {
78+
aa = 123
79+
})
80+
81+
p5(hhhh
82+
+ joijfoiji,
83+
{
84+
ok = main
85+
})
86+
87+
p6(haode
88+
+ jjjjj,
89+
function()
90+
91+
end)

0 commit comments

Comments
 (0)