@@ -1320,6 +1320,11 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatFunctionStatement(std::shared
13201320 }
13211321 case LuaAstNodeType::FunctionBody:
13221322 {
1323+ if (_options.space_before_function_open_parenthesis )
1324+ {
1325+ env->Add <KeepBlankElement>(1 );
1326+ }
1327+
13231328 env->AddChild (FormatNode (child));
13241329 break ;
13251330 }
@@ -1449,6 +1454,10 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatClosureExpression(std::shared
14491454 }
14501455 case LuaAstNodeType::FunctionBody:
14511456 {
1457+ if (_options.space_before_function_open_parenthesis )
1458+ {
1459+ env->Add <KeepBlankElement>(1 );
1460+ }
14521461 env->AddChild (FormatNode (child));
14531462 break ;
14541463 }
@@ -2287,7 +2296,20 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatIndexExpression(std::shared_p
22872296 default :
22882297 {
22892298 FormatSubExpression (child, env);
2290- env->Add <KeepElement>(0 );
2299+
2300+ auto nextNode = NextNode (it, children);
2301+ if (_options.space_before_open_square_bracket
2302+ && nextNode != nullptr
2303+ && nextNode->GetType () == LuaAstNodeType::IndexOperator
2304+ && nextNode->GetTokenType () == ' ['
2305+ && !StringUtil::EndWith (child->GetText (), " ]" ))
2306+ {
2307+ env->Add <KeepElement>(1 );
2308+ }
2309+ else
2310+ {
2311+ env->Add <KeepElement>(0 );
2312+ }
22912313 }
22922314 }
22932315 }
@@ -2313,7 +2335,8 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatCallExpression(std::shared_pt
23132335 auto next = NextNode (it, children);
23142336 if (next && next->GetType () == LuaAstNodeType::CallArgList)
23152337 {
2316- if (!ast_util::WillCallArgHaveParentheses (next, _options.call_arg_parentheses ))
2338+ if (!ast_util::WillCallArgHaveParentheses (next, _options.call_arg_parentheses ) || _options.
2339+ space_before_function_open_parenthesis)
23172340 {
23182341 // TODO workaround
23192342 env->Add <KeepElement>(1 , false , false );
0 commit comments