Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrap_comments creating invalid code blocks #6417

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {}
Loading