Index: tools/gn/command_format.cc |
diff --git a/tools/gn/command_format.cc b/tools/gn/command_format.cc |
index 96170b298e0c4b4639877b3a19f75b4d8165bb55..0a110f1b6af5a6f42a0b7a26dee51141104461c3 100644 |
--- a/tools/gn/command_format.cc |
+++ b/tools/gn/command_format.cc |
@@ -122,14 +122,22 @@ void Printer::Newline() { |
if (!comments_.empty()) { |
Print(" "); |
int i = 0; |
+ // Save the margin, and temporarily set it to where the first comment |
+ // starts so that multiple suffix comments are vertically aligned. This |
+ // will need to be fancier once we enforce 80 col. |
+ int old_margin = margin_; |
for (const auto& c : comments_) { |
- if (i > 0) { |
+ if (i == 0) |
+ margin_ = CurrentColumn(); |
+ else { |
Trim(); |
Print("\n"); |
PrintMargin(); |
} |
TrimAndPrintToken(c); |
+ ++i; |
} |
+ margin_ = old_margin; |
comments_.clear(); |
} |
Trim(); |