Skip to content

Commit

Permalink
Check newline
Browse files Browse the repository at this point in the history
  • Loading branch information
Matts966 committed Apr 24, 2022
1 parent 85187ee commit b7ba232
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions zetasql/parser/unparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@ std::string UnparseWithComments(const ASTNode* node, std::deque<std::pair<std::s
// Print comments by visitors and pop.
node->Accept(&unparser, &parse_tokens);
// Emit left comments in parse_tokens.
bool newline_emitted = false;
for (const auto& parse_token : parse_tokens) {
unparser.println(parse_token.first);
if (parse_token.first.find("\n") != std::string::npos) {
newline_emitted = true;
}
unparser.print(parse_token.first);
}
if (!newline_emitted) {
unparser.FlushLine();
}
unparser.FlushLine();
return unparsed_;
}

Expand Down

0 comments on commit b7ba232

Please # to comment.