@@ -34,18 +34,22 @@ pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContex
34
34
AssistId ( "change_return_type_to_result" ) ,
35
35
"Change return type to Result" ,
36
36
type_ref. syntax ( ) . text_range ( ) ,
37
- |edit | {
37
+ |builder | {
38
38
let mut tail_return_expr_collector = TailReturnCollector :: new ( ) ;
39
39
tail_return_expr_collector. collect_jump_exprs ( block_expr, false ) ;
40
40
tail_return_expr_collector. collect_tail_exprs ( block_expr) ;
41
41
42
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
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
)
0 commit comments