Skip to content

Commit 604764a

Browse files
committed
Trim custom comment prefix even when we failed to format code block
1 parent 1b4778d commit 604764a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/comment.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,10 @@ fn rewrite_comment_inner(
390390
let code_block = {
391391
let mut config = config.clone();
392392
config.set().wrap_comments(false);
393-
::format_code_block(&code_block_buffer, &config)
394-
.map_or_else(|| code_block_buffer.to_owned(), trim_custom_comment_prefix)
393+
match ::format_code_block(&code_block_buffer, &config) {
394+
Some(ref s) => trim_custom_comment_prefix(s),
395+
None => trim_custom_comment_prefix(&code_block_buffer),
396+
}
395397
};
396398
result.push_str(&join_code_block_with_comment_line_separator(&code_block));
397399
code_block_buffer.clear();

0 commit comments

Comments
 (0)