summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/gn/command_format.cc10
-rw-r--r--tools/gn/command_format_unittest.cc1
-rw-r--r--tools/gn/format_test_data/020.gn5
-rw-r--r--tools/gn/format_test_data/020.golden5
4 files changed, 20 insertions, 1 deletions
diff --git a/tools/gn/command_format.cc b/tools/gn/command_format.cc
index 96170b2..0a110f1 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();
diff --git a/tools/gn/command_format_unittest.cc b/tools/gn/command_format_unittest.cc
index 4c59c28..bb9c6fd 100644
--- a/tools/gn/command_format_unittest.cc
+++ b/tools/gn/command_format_unittest.cc
@@ -48,3 +48,4 @@ FORMAT_TEST(015)
FORMAT_TEST(017)
FORMAT_TEST(018)
FORMAT_TEST(019)
+FORMAT_TEST(020)
diff --git a/tools/gn/format_test_data/020.gn b/tools/gn/format_test_data/020.gn
new file mode 100644
index 0000000..96de164
--- /dev/null
+++ b/tools/gn/format_test_data/020.gn
@@ -0,0 +1,5 @@
+cflags = [
+ "/wd4267", # size_t -> int.
+ "/wd4324", # Structure was padded due to __declspec(align()), which is
+ # uninteresting.
+]
diff --git a/tools/gn/format_test_data/020.golden b/tools/gn/format_test_data/020.golden
new file mode 100644
index 0000000..96de164
--- /dev/null
+++ b/tools/gn/format_test_data/020.golden
@@ -0,0 +1,5 @@
+cflags = [
+ "/wd4267", # size_t -> int.
+ "/wd4324", # Structure was padded due to __declspec(align()), which is
+ # uninteresting.
+]