Skip to content

Commit

Permalink
fix: backport fix for #4079
Browse files Browse the repository at this point in the history
  • Loading branch information
calebcartwright committed Jun 12, 2020
1 parent 5db7152 commit 796d6ea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@ impl<'a> CommentRewrite<'a> {
.checked_sub(closer.len() + opener.len())
.unwrap_or(1);
let indent_str = shape.indent.to_string_with_newline(config).to_string();
let fmt_indent = shape.indent + (opener.len() - line_start.len());

let mut cr = CommentRewrite {
result: String::with_capacity(orig.len() * 2),
Expand All @@ -540,14 +539,14 @@ impl<'a> CommentRewrite<'a> {
comment_line_separator: format!("{}{}", indent_str, line_start),
max_width,
indent_str,
fmt_indent,
fmt_indent: shape.indent,

fmt: StringFormat {
opener: "",
closer: "",
line_start,
line_end: "",
shape: Shape::legacy(max_width, fmt_indent),
shape: Shape::legacy(max_width, shape.indent),
trim_end: true,
config,
},
Expand Down
8 changes: 8 additions & 0 deletions tests/source/issue-4079.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// rustfmt-wrap_comments: true

/*!
* Lorem ipsum dolor sit amet, consectetur adipiscing elit. In lacinia
* ullamcorper lorem, non hendrerit enim convallis ut. Curabitur id sem volutpat
*/

/*! Lorem ipsum dolor sit amet, consectetur adipiscing elit. In lacinia ullamcorper lorem, non hendrerit enim convallis ut. Curabitur id sem volutpat */
11 changes: 11 additions & 0 deletions tests/target/issue-4079.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// rustfmt-wrap_comments: true

/*!
* Lorem ipsum dolor sit amet, consectetur adipiscing elit. In lacinia
* ullamcorper lorem, non hendrerit enim convallis ut. Curabitur id sem
* volutpat
*/

/*! Lorem ipsum dolor sit amet, consectetur adipiscing elit. In lacinia
* ullamcorper lorem, non hendrerit enim convallis ut. Curabitur id sem
* volutpat */

0 comments on commit 796d6ea

Please sign in to comment.