Keep blank lines around comments with range
@@ -250,9 +250,18 @@ impl<'a> FmtVisitor<'a> {
}
}
- // cur_line += newline_count;
- // rewirte_next_comment = true;
-
+ let newline_count = count_newlines(&subslice);
+ if subslice.trim().is_empty() && newline_count > 0
+ && self.config.file_lines().intersects_range(
+ file_name,
+ status.cur_line,
+ status.cur_line + newline_count,
+ ) {
+ self.push_vertical_spaces(newline_count);
+ status.cur_line += newline_count;
+ status.rewrite_next_comment = true;
+ status.line_start = offset + newline_count;
+ } else {
for (mut i, c) in subslice.char_indices() {
i += offset;
@@ -299,6 +308,7 @@ impl<'a> FmtVisitor<'a> {
status.rewrite_next_comment = true;
}
}
+ }
process_last_snippet(self, &snippet[status.line_start..], snippet);
}
