This commit is contained in:
Ali Bektas 2023-09-22 13:32:20 +02:00
parent 0863024b1a
commit 0a91a54794
2 changed files with 20 additions and 20 deletions

View file

@ -89,12 +89,12 @@ fn line_to_block(acc: &mut Assists, comment: ast::Comment) -> Option<()> {
// contents of each line comment when they're put into the block comment.
let indentation = IndentLevel::from_token(comment.syntax());
let cms = comments
let block_comment_body = comments
.into_iter()
.map(|c| line_comment_text(indentation, c))
.collect::<Vec<String>>();
let block_comment_body = cms.into_iter().join("\n");
.collect::<Vec<String>>()
.into_iter()
.join("\n");
let block_prefix =
CommentKind { shape: CommentShape::Block, ..comment.kind() }.prefix();

View file

@ -55,27 +55,27 @@ pub(crate) fn desugar_doc_comment(acc: &mut Assists, ctx: &AssistContext<'_>) ->
}
};
let text = match comments {
Either::Left(comment) => {
let text = comment.text();
text[comment.prefix().len()..(text.len() - "*/".len())]
.trim()
.lines()
.map(|l| l.strip_prefix(&indentation).unwrap_or(l))
.join("\n")
}
Either::Right(comments) => comments
.into_iter()
.map(|cm| line_comment_text(IndentLevel(0), cm))
.collect::<Vec<_>>()
.join("\n"),
};
acc.add(
AssistId("desugar_doc_comment", AssistKind::RefactorRewrite),
"Desugar doc-comment to attribute macro",
target,
|edit| {
let text = match comments {
Either::Left(comment) => {
let text = comment.text();
text[comment.prefix().len()..(text.len() - "*/".len())]
.trim()
.lines()
.map(|l| l.strip_prefix(&indentation).unwrap_or(l))
.join("\n")
}
Either::Right(comments) => comments
.into_iter()
.map(|cm| line_comment_text(IndentLevel(0), cm))
.collect::<Vec<_>>()
.join("\n"),
};
let hashes = "#".repeat(required_hashes(&text));
let prefix = match placement {