Suppress hardbreaks when following hardbreaks.

This commit is contained in:
Graydon Hoare 2011-06-20 16:15:11 +00:00
parent 035d60d533
commit 8cd0695230
2 changed files with 7 additions and 6 deletions

View File

@ -235,7 +235,7 @@ fn print_comment(&ps s, lexer::cmnt cmnt) {
zerobreak(s.s);
}
case (lexer::isolated) {
pprust::hardbreak_if_not_eof(s);
pprust::hardbreak_if_not_bol(s);
for (str line in cmnt.lines) { word(s.s, line); hardbreak(s.s); }
}
case (lexer::trailing) {

View File

@ -120,8 +120,9 @@ fn bclose(&ps s, common::span span) {
}
fn hardbreak_if_not_eof(&ps s) {
if (s.s.last_token() != pp::EOF) {
fn hardbreak_if_not_bol(&ps s) {
if (s.s.last_token() != pp::EOF &&
s.s.last_token() != pp::hardbreak_tok()) {
hardbreak(s.s);
}
}
@ -183,7 +184,7 @@ fn print_mod(&ps s, ast::_mod _mod) {
for (@ast::item item in _mod.items) {
// Mod-level item printing we're a little more space-y about.
hardbreak_if_not_eof(s);
hardbreak_if_not_bol(s);
print_item(s, item);
}
print_remaining_comments(s);
@ -271,7 +272,7 @@ fn print_type(&ps s, &ast::ty ty) {
}
fn print_item(&ps s, &@ast::item item) {
hardbreak_if_not_eof(s);
hardbreak_if_not_bol(s);
maybe_print_comment(s, item.span.lo);
print_outer_attributes(s, item.attrs);
alt (item.node) {
@ -1025,7 +1026,7 @@ fn print_meta_item(&ps s, &@ast::meta_item item) {
}
fn print_view_item(&ps s, &@ast::view_item item) {
hardbreak_if_not_eof(s);
hardbreak_if_not_bol(s);
maybe_print_comment(s, item.span.lo);
alt (item.node) {
case (ast::view_item_use(?id, ?mta, _, _)) {