Skip to content

Commit

Permalink
Allow printing of consecutive empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Feb 14, 2023
1 parent 7cc998e commit ed6d2a8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/ruff_formatter/src/printer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl<'a> Printer<'a> {
}

// Print a second line break if this is an empty line
if line_mode == &LineMode::Empty && !self.state.has_empty_line {
if line_mode == &LineMode::Empty {
self.print_str("\n");
self.state.has_empty_line = true;
}
Expand Down Expand Up @@ -1445,7 +1445,7 @@ two lines`,
}

#[test]
fn it_prints_consecutive_empty_lines_as_one() {
fn it_prints_consecutive_empty_lines_as_many() {
let result = format(&format_args![
text("a"),
empty_line(),
Expand All @@ -1454,11 +1454,11 @@ two lines`,
text("b"),
]);

assert_eq!("a\n\nb", result.as_code())
assert_eq!("a\n\n\n\nb", result.as_code())
}

#[test]
fn it_prints_consecutive_mixed_lines_as_one() {
fn it_prints_consecutive_mixed_lines_as_many() {
let result = format(&format_args![
text("a"),
empty_line(),
Expand All @@ -1468,7 +1468,7 @@ two lines`,
text("b"),
]);

assert_eq!("a\n\nb", result.as_code())
assert_eq!("a\n\n\nb", result.as_code())
}

#[test]
Expand Down

0 comments on commit ed6d2a8

Please sign in to comment.