Skip to content

Commit

Permalink
fix: wrap_comments creating invalid code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
grant0417 committed Dec 12, 2024
1 parent 8a2c073 commit 99943dd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,9 @@ impl<'a> CommentRewrite<'a> {
// Remove space if this is an empty comment or a doc comment.
self.result.pop();
}
if self.code_block_attr.is_some() && self.is_prev_line_multi_line {
self.result.push_str(&self.comment_line_separator);
}
self.result.push_str(line);
self.fmt.shape = Shape::legacy(self.max_width, self.fmt_indent);
self.is_prev_line_multi_line = false;
Expand Down
7 changes: 7 additions & 0 deletions tests/target/issue-5244/unwrapped.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// rustfmt-wrap_comments: false

/// Here is me writing some documentation that is too long oh me oh my now some code please!
/// ```
/// test
/// ```
fn foo() {}
8 changes: 8 additions & 0 deletions tests/target/issue-5244/wrapped.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// rustfmt-wrap_comments: true

/// Here is me writing some documentation that is too long oh me oh my now some
/// code please!
/// ```
/// test
/// ```
fn foo() {}

0 comments on commit 99943dd

Please sign in to comment.