Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Unified Diff: tools/gn/command_format.cc

Issue 613473002: gn format: properly break and align multiple suffix comments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-list-comment-spacing
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/gn/command_format_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | tools/gn/command_format_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698