diff --git a/src/comment.rs b/src/comment.rs index 17b4af1717d..bc0e8774f49 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -432,7 +432,7 @@ impl CodeBlockAttribute { /// Block that is formatted as an item. /// -/// An item starts with either a star `*` a dash `-` or a greater-than `>`. +/// An item starts with either a star `*` a dash `-` a greater-than `>` or a plus '+'. /// Different level of indentation are handled by shrinking the shape accordingly. struct ItemizedBlock { /// the lines that are identified as part of an itemized block @@ -449,7 +449,8 @@ impl ItemizedBlock { /// Returns `true` if the line is formatted as an item fn is_itemized_line(line: &str) -> bool { let trimmed = line.trim_start(); - trimmed.starts_with("* ") || trimmed.starts_with("- ") || trimmed.starts_with("> ") + let itemized_start = ["* ", "- ", "> ", "+ "]; + itemized_start.iter().any(|s| trimmed.starts_with(s)) } /// Creates a new ItemizedBlock described with the given line. diff --git a/tests/source/issue-4041.rs b/tests/source/issue-4041.rs new file mode 100644 index 00000000000..274b80f1bc5 --- /dev/null +++ b/tests/source/issue-4041.rs @@ -0,0 +1,5 @@ +// rustfmt-wrap_comments: true +//! List: +//! - Sub list: +//! + very long #1 blah blah blah blah blah blah blah blah blah blah blah blah foo baar baxxxxxxxx long line 1231421230912i3091238192038 +//! + very long #2 blah blah blah blah blah blah blah blah blah blah blah blah diff --git a/tests/target/issue-4041.rs b/tests/target/issue-4041.rs new file mode 100644 index 00000000000..e9c693836f2 --- /dev/null +++ b/tests/target/issue-4041.rs @@ -0,0 +1,6 @@ +// rustfmt-wrap_comments: true +//! List: +//! - Sub list: +//! + very long #1 blah blah blah blah blah blah blah blah blah blah blah blah +//! foo baar baxxxxxxxx long line 1231421230912i3091238192038 +//! + very long #2 blah blah blah blah blah blah blah blah blah blah blah blah