Removes */ in block doc comments
This commit is contained in:
@@ -115,7 +115,7 @@ pub trait DocCommentsOwner: AstNode {
|
||||
}
|
||||
|
||||
/// Returns the textual content of a doc comment block as a single string.
|
||||
/// That is, strips leading `///` (+ optional 1 character of whitespace)
|
||||
/// That is, strips leading `///` or trailing `*/` (+ optional 1 character of whitespace in either direction)
|
||||
/// and joins lines.
|
||||
fn doc_comment_text(&self) -> Option<String> {
|
||||
let mut has_comments = false;
|
||||
@@ -136,7 +136,18 @@ pub trait DocCommentsOwner: AstNode {
|
||||
prefix_len
|
||||
};
|
||||
|
||||
line[pos..].to_owned()
|
||||
let end = if comment.kind().shape.is_block() && line.ends_with("*/") {
|
||||
// FIXME: Use `nth_back` here once stable
|
||||
if line.chars().rev().nth(2).map(|c| c.is_whitespace()).unwrap_or(false) {
|
||||
line.len() - 3
|
||||
} else {
|
||||
line.len() - 2
|
||||
}
|
||||
} else {
|
||||
line.len()
|
||||
};
|
||||
|
||||
line[pos..end].to_owned()
|
||||
})
|
||||
.join("\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user