mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-18 15:31:25 +00: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:
@ -388,10 +388,12 @@ fn reset_indentation(s: &str) -> String {
|
|||||||
indent = indent.saturating_sub(1);
|
indent = indent.saturating_sub(1);
|
||||||
}
|
}
|
||||||
let extra = if line.starts_with(':') || line.starts_with('?') { 1 } else { 0 };
|
let extra = if line.starts_with(':') || line.starts_with('?') { 1 } else { 0 };
|
||||||
for _ in 0..indent + extra {
|
if !line.is_empty() {
|
||||||
dst.push_str(" ");
|
for _ in 0..indent + extra {
|
||||||
|
dst.push_str(" ");
|
||||||
|
}
|
||||||
|
dst.push_str(line);
|
||||||
}
|
}
|
||||||
dst.push_str(line);
|
|
||||||
dst.push_str("\n");
|
dst.push_str("\n");
|
||||||
if line.ends_with('{') {
|
if line.ends_with('{') {
|
||||||
indent += 1;
|
indent += 1;
|
||||||
|
Reference in New Issue
Block a user