Skip to content

Commit 0863024

Browse files
committed
Make assist lazy again
1 parent 2fdf7e4 commit 0863024

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

crates/ide-assists/src/handlers/convert_comment_block.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,21 @@ fn line_to_block(acc: &mut Assists, comment: ast::Comment) -> Option<()> {
7979
comments.last()?.syntax().text_range().end(),
8080
);
8181

82-
// We pick a single indentation level for the whole block comment based on the
83-
// comment where the assist was invoked. This will be prepended to the
84-
// contents of each line comment when they're put into the block comment.
85-
let indentation = IndentLevel::from_token(comment.syntax());
86-
87-
let cms =
88-
comments.into_iter().map(|c| line_comment_text(indentation, c)).collect::<Vec<String>>();
89-
9082
acc.add(
9183
AssistId("line_to_block", AssistKind::RefactorRewrite),
9284
"Replace line comments with a single block comment",
9385
target,
9486
|edit| {
87+
// We pick a single indentation level for the whole block comment based on the
88+
// comment where the assist was invoked. This will be prepended to the
89+
// contents of each line comment when they're put into the block comment.
90+
let indentation = IndentLevel::from_token(comment.syntax());
91+
92+
let cms = comments
93+
.into_iter()
94+
.map(|c| line_comment_text(indentation, c))
95+
.collect::<Vec<String>>();
96+
9597
let block_comment_body = cms.into_iter().join("\n");
9698

9799
let block_prefix =

0 commit comments

Comments
 (0)