@@ -135,8 +135,6 @@ void SpaceAnalyzer::ComplexAnalyze(FormatState &f, const LuaSyntaxTree &t) {
135135 auto rightBrace = syntaxNode.GetChildToken (' )' , t);
136136 SpaceRight (leftBrace, t, 1 );
137137 SpaceLeft (rightBrace, t, 1 );
138- } else {
139- SpaceLeft (syntaxNode, t, 0 );
140138 }
141139 if (f.GetStyle ().ignore_spaces_inside_function_call ) {
142140 auto exprList = syntaxNode.GetChildSyntaxNode (LuaSyntaxNodeKind::ExpressionList, t);
@@ -147,8 +145,17 @@ void SpaceAnalyzer::ComplexAnalyze(FormatState &f, const LuaSyntaxTree &t) {
147145 }
148146 }
149147 }
148+ if (f.GetStyle ().space_before_function_call_open_parenthesis ) {
149+ SpaceLeft (leftBrace, t, 1 );
150+ } else {
151+ SpaceLeft (leftBrace, t, 0 );
152+ }
150153 } else {
151- SpaceLeft (syntaxNode, t, 1 );
154+ if (f.GetStyle ().space_before_function_call_single_arg ) {
155+ SpaceLeft (syntaxNode, t, 1 );
156+ } else {
157+ SpaceLeft (syntaxNode, t, 0 );
158+ }
152159 }
153160 break ;
154161 }
@@ -228,12 +235,19 @@ void SpaceAnalyzer::ComplexAnalyze(FormatState &f, const LuaSyntaxTree &t) {
228235 }
229236 case LuaSyntaxNodeKind::FunctionBody: {
230237 auto leftBrace = syntaxNode.GetChildToken (' (' , t);
231- if (f.GetStyle ().space_before_function_open_parenthesis ) {
232- SpaceLeft (leftBrace, t, 1 );
238+ if (syntaxNode.GetParent (t).GetSyntaxKind (t) == LuaSyntaxNodeKind::ClosureExpression) {
239+ if (f.GetStyle ().space_before_closure_open_parenthesis ) {
240+ SpaceLeft (leftBrace, t, 1 );
241+ } else {
242+ SpaceLeft (leftBrace, t, 0 );
243+ }
233244 } else {
234- SpaceLeft (leftBrace, t, 0 );
245+ if (f.GetStyle ().space_before_function_open_parenthesis ) {
246+ SpaceLeft (leftBrace, t, 1 );
247+ } else {
248+ SpaceLeft (leftBrace, t, 0 );
249+ }
235250 }
236-
237251 if (f.GetStyle ().space_inside_function_param_list_parentheses ) {
238252 auto next = leftBrace.GetNextToken (t);
239253 if (next.GetTokenKind (t) != ' )' ) {
0 commit comments