aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/handlers')
-rw-r--r--crates/ra_assists/src/handlers/change_return_type_to_result.rs12
1 files changed, 8 insertions, 4 deletions
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
34 AssistId("change_return_type_to_result"), 34 AssistId("change_return_type_to_result"),
35 "Change return type to Result", 35 "Change return type to Result",
36 type_ref.syntax().text_range(), 36 type_ref.syntax().text_range(),
37 |edit| { 37 |builder| {
38 let mut tail_return_expr_collector = TailReturnCollector::new(); 38 let mut tail_return_expr_collector = TailReturnCollector::new();
39 tail_return_expr_collector.collect_jump_exprs(block_expr, false); 39 tail_return_expr_collector.collect_jump_exprs(block_expr, false);
40 tail_return_expr_collector.collect_tail_exprs(block_expr); 40 tail_return_expr_collector.collect_tail_exprs(block_expr);
41 41
42 for ret_expr_arg in tail_return_expr_collector.exprs_to_wrap { 42 for ret_expr_arg in tail_return_expr_collector.exprs_to_wrap {
43 edit.replace_node_and_indent(&ret_expr_arg, format!("Ok({})", ret_expr_arg)); 43 builder.replace_node_and_indent(&ret_expr_arg, format!("Ok({})", ret_expr_arg));
44 } 44 }
45 edit.replace_node_and_indent(type_ref.syntax(), format!("Result<{}, >", type_ref)); 45 match ctx.config.snippet_cap {
46 Some(_) => {}
47 None => {}
48 }
49 builder.replace_node_and_indent(type_ref.syntax(), format!("Result<{}, >", type_ref));
46 50
47 if let Some(node_start) = result_insertion_offset(&type_ref) { 51 if let Some(node_start) = result_insertion_offset(&type_ref) {
48 edit.set_cursor(node_start + TextSize::of(&format!("Result<{}, ", type_ref))); 52 builder.set_cursor(node_start + TextSize::of(&format!("Result<{}, ", type_ref)));
49 } 53 }
50 }, 54 },
51 ) 55 )