Add unwrap block assist #4156

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
Benjamin Coenen 2020-05-02 12:31:11 +02:00
parent 0b40876b99
commit 6d5f3922f7

View file

@ -76,12 +76,11 @@ pub(crate) fn unwrap_block(ctx: AssistCtx) -> Option<Assist> {
})
}
fn extract_expr(cursor_range: TextRange, block_expr: BlockExpr) -> Option<Expr> {
let block = block_expr.block()?;
fn extract_expr(cursor_range: TextRange, block: BlockExpr) -> Option<Expr> {
let cursor_in_range = block.l_curly_token()?.text_range().contains_range(cursor_range);
if cursor_in_range {
Some(unwrap_trivial_block(block_expr))
Some(unwrap_trivial_block(block))
} else {
None
}