From d790a443f396ad53037a3f6ba794b6f4df5b3748 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 10:30:18 +0200 Subject: wip --- .../ra_assists/src/handlers/change_return_type_to_result.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'crates/ra_assists/src/handlers') diff --git a/crates/ra_assists/src/handlers/change_return_type_to_result.rs b/crates/ra_assists/src/handlers/change_return_type_to_result.rs index ae8237c5d..c9f909f9c 100644 --- a/crates/ra_assists/src/handlers/change_return_type_to_result.rs +++ b/crates/ra_assists/src/handlers/change_return_type_to_result.rs @@ -34,18 +34,22 @@ pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContex AssistId("change_return_type_to_result"), "Change return type to Result", type_ref.syntax().text_range(), - |edit| { + |builder| { let mut tail_return_expr_collector = TailReturnCollector::new(); tail_return_expr_collector.collect_jump_exprs(block_expr, false); tail_return_expr_collector.collect_tail_exprs(block_expr); for ret_expr_arg in tail_return_expr_collector.exprs_to_wrap { - edit.replace_node_and_indent(&ret_expr_arg, format!("Ok({})", ret_expr_arg)); + builder.replace_node_and_indent(&ret_expr_arg, format!("Ok({})", ret_expr_arg)); } - edit.replace_node_and_indent(type_ref.syntax(), format!("Result<{}, >", type_ref)); + match ctx.config.snippet_cap { + Some(_) => {} + None => {} + } + builder.replace_node_and_indent(type_ref.syntax(), format!("Result<{}, >", type_ref)); if let Some(node_start) = result_insertion_offset(&type_ref) { - edit.set_cursor(node_start + TextSize::of(&format!("Result<{}, ", type_ref))); + builder.set_cursor(node_start + TextSize::of(&format!("Result<{}, ", type_ref))); } }, ) -- cgit v1.2.3