Skip to content

Commit

Permalink
Issue 4079 (#4080)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahl authored Mar 31, 2020
1 parent 4d22687 commit a0eb97b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
5 changes: 2 additions & 3 deletions rustfmt-core/rustfmt-lib/src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,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 @@ -539,14 +538,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 rustfmt-core/rustfmt-lib/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 rustfmt-core/rustfmt-lib/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 a0eb97b

Please sign in to comment.