From ccc487ade798231a41cff965672c14d1a19145a4 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Sun, 17 Dec 2017 15:25:24 +0900 Subject: [PATCH] Do not put comment's line start and closer on the same line --- src/comment.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/comment.rs b/src/comment.rs index 6423ebca477..441bb858e2a 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -333,6 +333,9 @@ fn rewrite_comment_inner( } } else if is_prev_line_multi_line && !line.is_empty() { result.push(' ') + } else if is_last && !closer.is_empty() && line.is_empty() { + result.push('\n'); + result.push_str(&indent_str); } else { result.push_str(&comment_line_separator); if !has_leading_whitespace && result.ends_with(' ') { @@ -393,7 +396,7 @@ fn rewrite_comment_inner( Shape::legacy(max_chars, fmt_indent) }; } else { - if line.is_empty() && result.ends_with(' ') { + if line.is_empty() && result.ends_with(' ') && !is_last { // Remove space if this is an empty comment or a doc comment. result.pop(); }