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:
Nick Cameron 2018-11-06 10:23:30 +13:00 committed by GitHub
commit 16d5f507b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View File

@ -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;
}

View 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() {}

View 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() {}