Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lists doc comments fix4041 #5560

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions tests/source/issue-4041.rs
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tests/target/issue-4041.rs
Original file line number Diff line number Diff line change
@@ -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