[command_args] Strip the preceding whitespace in comments if not padding

For json output, the space between the # and the comment itself was not
stripped, this fixes it.

Change-Id: I8e8699785cb9444f895bfdd8795ee88b01acc0bf
Reviewed-on: https://gn-review.googlesource.com/2080
Reviewed-by: Brett Wilson <brettw@chromium.org>
Commit-Queue: Brett Wilson <brettw@chromium.org>
diff --git a/tools/gn/command_args.cc b/tools/gn/command_args.cc
index 64ae362..4e3a43f 100644
--- a/tools/gn/command_args.cc
+++ b/tools/gn/command_args.cc
@@ -72,9 +72,14 @@
   // normal comment that has a space after the # will be indented 4 spaces
   // (which makes our formatting come out nicely). If the comment is indented
   // from there, we want to preserve that indenting.
+  std::string line_stripped = line.substr(line.find('#') + 1).as_string();
   if (pad)
-    return "   " + line.substr(line.find('#') + 1).as_string();
-  return line.substr(line.find('#') + 1).as_string();
+    return "   " + line_stripped;
+
+  // If not padding, strip the leading space if present.
+  if (!line_stripped.empty() && line_stripped[0] == ' ')
+    return line_stripped.substr(1);
+  return line_stripped;
 }
 
 // Tries to find the comment before the setting of the given value.