reset_indentation: Don't emit indentation on blank lines

This resulted in trailing whitespace in the generated file. In addition
to wasting space in a file that gets served over the wire, this also
gets highlighted as a problem when reviewing the generated file in an
editor that highlights trailing whitespace.
This commit is contained in:
Josh Triplett 2018-09-13 22:13:07 -07:00
parent 1c52fb1b2f
commit 96a70c41be

View File

@ -388,10 +388,12 @@ fn reset_indentation(s: &str) -> String {
indent = indent.saturating_sub(1);
}
let extra = if line.starts_with(':') || line.starts_with('?') { 1 } else { 0 };
for _ in 0..indent + extra {
dst.push_str(" ");
if !line.is_empty() {
for _ in 0..indent + extra {
dst.push_str(" ");
}
dst.push_str(line);
}
dst.push_str(line);
dst.push_str("\n");
if line.ends_with('{') {
indent += 1;