Do better at preserving blank lines during pretty-printing
This commit is contained in:
parent
8c3ed8640b
commit
113be53df3
@ -1563,7 +1563,11 @@ fn print_comment(s: &ps, cmnt: lexer::cmnt) {
|
||||
}
|
||||
lexer::blank_line. {
|
||||
// We need to do at least one, possibly two hardbreaks.
|
||||
if is_begin(s) || is_end(s) { hardbreak(s.s) }
|
||||
let is_semi = alt s.s.last_token() {
|
||||
pp::STRING(s, _) { s == ";" }
|
||||
_ { false }
|
||||
};
|
||||
if is_semi || is_begin(s) || is_end(s) { hardbreak(s.s) }
|
||||
hardbreak(s.s);
|
||||
}
|
||||
}
|
||||
|
15
src/test/pretty/blank-lines.rs
Normal file
15
src/test/pretty/blank-lines.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// pp-exact
|
||||
fn f() -> [int] {
|
||||
let picard = 0;
|
||||
|
||||
let data = 1;
|
||||
|
||||
let worf = 2;
|
||||
|
||||
|
||||
let enterprise = [picard, data, worf];
|
||||
|
||||
|
||||
|
||||
ret enterprise;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user