Skip to content

Commit e2996a8

Browse files
authored
Lists doc comments fix4041 (#5560)
* add + start of an itemized line * add test * fix format * fix tests * update doc comment
1 parent 3f36c99 commit e2996a8

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/comment.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ impl CodeBlockAttribute {
432432

433433
/// Block that is formatted as an item.
434434
///
435-
/// An item starts with either a star `*` a dash `-` or a greater-than `>`.
435+
/// An item starts with either a star `*` a dash `-` a greater-than `>` or a plus '+'.
436436
/// Different level of indentation are handled by shrinking the shape accordingly.
437437
struct ItemizedBlock {
438438
/// the lines that are identified as part of an itemized block
@@ -449,7 +449,8 @@ impl ItemizedBlock {
449449
/// Returns `true` if the line is formatted as an item
450450
fn is_itemized_line(line: &str) -> bool {
451451
let trimmed = line.trim_start();
452-
trimmed.starts_with("* ") || trimmed.starts_with("- ") || trimmed.starts_with("> ")
452+
let itemized_start = ["* ", "- ", "> ", "+ "];
453+
itemized_start.iter().any(|s| trimmed.starts_with(s))
453454
}
454455

455456
/// Creates a new ItemizedBlock described with the given line.

tests/source/issue-4041.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// rustfmt-wrap_comments: true
2+
//! List:
3+
//! - Sub list:
4+
//! + very long #1 blah blah blah blah blah blah blah blah blah blah blah blah foo baar baxxxxxxxx long line 1231421230912i3091238192038
5+
//! + very long #2 blah blah blah blah blah blah blah blah blah blah blah blah

tests/target/issue-4041.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// rustfmt-wrap_comments: true
2+
//! List:
3+
//! - Sub list:
4+
//! + very long #1 blah blah blah blah blah blah blah blah blah blah blah blah
5+
//! foo baar baxxxxxxxx long line 1231421230912i3091238192038
6+
//! + very long #2 blah blah blah blah blah blah blah blah blah blah blah blah

0 commit comments

Comments
 (0)