diff options
author | Aleksey Kladov <[email protected]> | 2020-05-20 09:30:18 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-05-20 09:30:18 +0100 |
commit | d790a443f396ad53037a3f6ba794b6f4df5b3748 (patch) | |
tree | d747ed36a0a47637cef5917ba3af9e8ed6b9bc21 /crates/ra_assists | |
parent | 2e74df4e2b79955a44dee79811e06b8fabff4da2 (diff) |
wip
Diffstat (limited to 'crates/ra_assists')
-rw-r--r-- | crates/ra_assists/src/handlers/change_return_type_to_result.rs | 12 |
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 | ) |