@@ -166,7 +166,7 @@ class ASTNode {
166166 void renderSectionLambdas (const llvm::json::Value &Contexts,
167167 llvm::raw_ostream &OS, SectionLambda &L);
168168
169- void indentTextNode (std::string &body , size_t Indentation, bool lastChild );
169+ void indentTextNode (std::string &Body , size_t Indentation, bool FinalNode );
170170
171171 void indentNodes (ASTNode *Node, bool isPartial);
172172
@@ -685,17 +685,19 @@ void ASTNode::renderChild(const json::Value &Contexts, llvm::raw_ostream &OS) {
685685 Child->render (Contexts, OS);
686686}
687687
688- void ASTNode::indentTextNode (std::string &body , size_t Indentation,
689- bool lastChild ) {
688+ void ASTNode::indentTextNode (std::string &Body , size_t Indentation,
689+ bool FinalNode ) {
690690 std::string spaces (Indentation, ' ' );
691691 size_t pos = 0 ;
692+ size_t LastChar = std::string::npos;
692693
693- if (lastChild)
694- body.erase (body.find_last_not_of (" \t\r\f\v " ) + 1 ); // .rtrim??
694+ if (FinalNode)
695+ // body.erase(body.find_last_not_of(" \t\r\f\v") + 1);
696+ LastChar = Body.find_last_not_of (" \t\r\f\v " );
695697
696- while ((pos = body .find (' \n ' , pos)) != std::string::npos) {
697- if ((!lastChild ) || (pos != body. size () - 1 )) {
698- body .insert (pos + 1 , spaces);
698+ while ((pos = Body .find (' \n ' , pos)) != std::string::npos) {
699+ if ((!FinalNode ) || (pos != LastChar )) {
700+ Body .insert (pos + 1 , spaces);
699701 pos += 1 + Indentation;
700702 } else {
701703 break ;
0 commit comments