Merge pull request #3172 from scampi/issue3153
trim the start of a line when wrapping an item in preparation for formatting
This commit is contained in:
commit
16d5f507b6
@ -398,7 +398,7 @@ impl CodeBlockAttribute {
|
||||
/// Block that is formatted as an item.
|
||||
///
|
||||
/// An item starts with either a star `*` or a dash `-`. Different level of indentation are
|
||||
/// handled.
|
||||
/// handled by shrinking the shape accordingly.
|
||||
struct ItemizedBlock {
|
||||
/// the number of whitespaces up to the item sigil
|
||||
indent: usize,
|
||||
@ -585,7 +585,7 @@ impl<'a> CommentRewrite<'a> {
|
||||
|
||||
if let Some(ref ib) = self.item_block {
|
||||
if ib.in_block(&line) {
|
||||
self.item_block_buffer.push_str(&line);
|
||||
self.item_block_buffer.push_str(line.trim_start());
|
||||
self.item_block_buffer.push('\n');
|
||||
return false;
|
||||
}
|
||||
|
9
tests/source/issue-3153.rs
Normal file
9
tests/source/issue-3153.rs
Normal file
@ -0,0 +1,9 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
|
||||
/// This may panic if:
|
||||
/// - there are fewer than `max_header_bytes` bytes preceding the body
|
||||
/// - there are fewer than `max_footer_bytes` bytes following the body
|
||||
/// - the sum of the body bytes and post-body bytes is less than the sum
|
||||
/// of `min_body_and_padding_bytes` and `max_footer_bytes` (in other
|
||||
/// words, the minimum body and padding byte requirement is not met)
|
||||
fn foo() {}
|
9
tests/target/issue-3153.rs
Normal file
9
tests/target/issue-3153.rs
Normal file
@ -0,0 +1,9 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
|
||||
/// This may panic if:
|
||||
/// - there are fewer than `max_header_bytes` bytes preceding the body
|
||||
/// - there are fewer than `max_footer_bytes` bytes following the body
|
||||
/// - the sum of the body bytes and post-body bytes is less than the sum of
|
||||
/// `min_body_and_padding_bytes` and `max_footer_bytes` (in other words, the
|
||||
/// minimum body and padding byte requirement is not met)
|
||||
fn foo() {}
|
Loading…
x
Reference in New Issue
Block a user