Unnamed repository; edit this file 'description' to name the repository.
Make assist lazy again
Ali Bektas 2023-09-11
parent 2fdf7e4 · commit 0863024
-rw-r--r--crates/ide-assists/src/handlers/convert_comment_block.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/crates/ide-assists/src/handlers/convert_comment_block.rs b/crates/ide-assists/src/handlers/convert_comment_block.rs
index 1f048ac10f..ef914cdb2c 100644
--- a/crates/ide-assists/src/handlers/convert_comment_block.rs
+++ b/crates/ide-assists/src/handlers/convert_comment_block.rs
@@ -79,19 +79,21 @@ fn line_to_block(acc: &mut Assists, comment: ast::Comment) -> Option<()> {
comments.last()?.syntax().text_range().end(),
);
- // We pick a single indentation level for the whole block comment based on the
- // comment where the assist was invoked. This will be prepended to the
- // contents of each line comment when they're put into the block comment.
- let indentation = IndentLevel::from_token(comment.syntax());
-
- let cms =
- comments.into_iter().map(|c| line_comment_text(indentation, c)).collect::<Vec<String>>();
-
acc.add(
AssistId("line_to_block", AssistKind::RefactorRewrite),
"Replace line comments with a single block comment",
target,
|edit| {
+ // We pick a single indentation level for the whole block comment based on the
+ // comment where the assist was invoked. This will be prepended to the
+ // contents of each line comment when they're put into the block comment.
+ let indentation = IndentLevel::from_token(comment.syntax());
+
+ let cms = comments
+ .into_iter()
+ .map(|c| line_comment_text(indentation, c))
+ .collect::<Vec<String>>();
+
let block_comment_body = cms.into_iter().join("\n");
let block_prefix =