@@ -728,20 +728,24 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatDoStatement(std::shared_ptr<L
728728 auto & children = doStatement->GetChildren ();
729729 auto it = children.begin ();
730730 bool singleLine = false ;
731- auto block = FormatNodeAndBlockOrEnd (it, singleLine, children);
731+ auto doBlockEnd = FormatNodeAndBlockOrEnd (it, singleLine, children);
732732
733- std::shared_ptr<FormatElement> childEnv = nullptr ;
734- if (_options.do_statement_no_indent )
733+ if (_options.do_statement_no_indent && !singleLine)
735734 {
736- childEnv = std::make_shared<NoIndentElement>();
737- childEnv->AddChild (block);
738- }
739- else
740- {
741- childEnv = block;
735+ for (auto & child : doBlockEnd->GetChildren ())
736+ {
737+ if (child->GetType () == FormatElementType::IndentElement)
738+ {
739+ auto indentElement = std::make_shared<IndentElement>();
740+ auto noIndent = std::make_shared<NoIndentElement>();
741+ noIndent->AddChildren (child->GetChildren ());
742+ indentElement->AddChild (noIndent);
743+ child = indentElement;
744+ }
745+ }
742746 }
743747
744- env->AddChild (childEnv );
748+ env->AddChild (doBlockEnd );
745749 return env;
746750}
747751
@@ -1062,7 +1066,7 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatCallArgList(std::shared_ptr<L
10621066 alignToFirstEnv->AddChildren (exprListEnv->GetChildren ());
10631067 env->AddChild (alignToFirstEnv);
10641068 }
1065- else
1069+ else
10661070 {
10671071 auto & exprListChildren = exprListEnv->GetChildren ();
10681072 auto keepElement = std::make_shared<KeepElement>(0 );
0 commit comments