From 04449c6622eb039ca71a74972dfdc6e28339c6cc Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Tue, 5 Dec 2017 17:38:27 +0900 Subject: [PATCH] Handle cases when bound changed from the default --- src/missed_spans.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/missed_spans.rs b/src/missed_spans.rs index 94bfc034db6f..a3cad47063e2 100644 --- a/src/missed_spans.rs +++ b/src/missed_spans.rs @@ -88,11 +88,9 @@ impl<'a> FmtVisitor<'a> { fn push_vertical_spaces(&mut self, mut newline_count: usize) { // The buffer already has a trailing newline. - if self.buffer.cur_offset() == 0 { - newline_count = newline_count.checked_sub(1).unwrap_or(0); - } - let newline_upper_bound = self.config.blank_lines_upper_bound() + 1; - let newline_lower_bound = self.config.blank_lines_lower_bound() + 1; + let offset = if self.buffer.cur_offset() == 0 { 0 } else { 1 }; + let newline_upper_bound = self.config.blank_lines_upper_bound() + offset; + let newline_lower_bound = self.config.blank_lines_lower_bound() + offset; if newline_count > newline_upper_bound { newline_count = newline_upper_bound; } else if newline_count < newline_lower_bound {