mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2025-01-01 16:04:51 +03:00
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:
parent
1c52fb1b2f
commit
96a70c41be
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user