From 0a91a54794cfd45bc927de4760332c6ac5559ac8 Mon Sep 17 00:00:00 2001 From: Ali Bektas Date: Fri, 22 Sep 2023 13:32:20 +0200 Subject: [PATCH] v4 --- .../src/handlers/convert_comment_block.rs | 8 ++--- .../src/handlers/desugar_doc_comment.rs | 32 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/crates/ide-assists/src/handlers/convert_comment_block.rs b/crates/ide-assists/src/handlers/convert_comment_block.rs index ef914cdb2cd..3f478ee7d39 100644 --- a/crates/ide-assists/src/handlers/convert_comment_block.rs +++ b/crates/ide-assists/src/handlers/convert_comment_block.rs @@ -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::>(); - - let block_comment_body = cms.into_iter().join("\n"); + .collect::>() + .into_iter() + .join("\n"); let block_prefix = CommentKind { shape: CommentShape::Block, ..comment.kind() }.prefix(); diff --git a/crates/ide-assists/src/handlers/desugar_doc_comment.rs b/crates/ide-assists/src/handlers/desugar_doc_comment.rs index b7919bd1502..c859e98524e 100644 --- a/crates/ide-assists/src/handlers/desugar_doc_comment.rs +++ b/crates/ide-assists/src/handlers/desugar_doc_comment.rs @@ -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::>() - .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::>() + .join("\n"), + }; + let hashes = "#".repeat(required_hashes(&text)); let prefix = match placement {