@@ -93,6 +93,7 @@ pub(crate) fn unwrap_return_type(acc: &mut Assists, ctx: &AssistContext<'_>) ->
9393 editor. replace ( type_ref. syntax ( ) , happy_type. syntax ( ) . clone_for_update ( ) ) ;
9494 }
9595
96+ let mut final_placeholder = None ;
9697 for tail_expr in exprs_to_unwrap {
9798 match & tail_expr {
9899 ast:: Expr :: CallExpr ( call_expr) => {
@@ -147,12 +148,27 @@ pub(crate) fn unwrap_return_type(acc: &mut Assists, ctx: &AssistContext<'_>) ->
147148 continue ;
148149 }
149150
150- editor. replace ( path_expr. syntax ( ) , make. expr_unit ( ) . syntax ( ) ) ;
151+ let new_tail_expr = make. expr_unit ( ) ;
152+ editor. replace ( path_expr. syntax ( ) , new_tail_expr. syntax ( ) ) ;
153+ if let Some ( cap) = ctx. config . snippet_cap {
154+ editor. add_annotation (
155+ new_tail_expr. syntax ( ) ,
156+ builder. make_placeholder_snippet ( cap) ,
157+ ) ;
158+
159+ final_placeholder = Some ( new_tail_expr) ;
160+ }
151161 }
152162 _ => ( ) ,
153163 }
154164 }
155165
166+ if let Some ( cap) = ctx. config . snippet_cap {
167+ if let Some ( final_placeholder) = final_placeholder {
168+ editor. add_annotation ( final_placeholder. syntax ( ) , builder. make_tabstop_after ( cap) ) ;
169+ }
170+ }
171+
156172 editor. add_mappings ( make. finish_with_mappings ( ) ) ;
157173 builder. add_file_edits ( ctx. file_id ( ) , editor) ;
158174 } )
@@ -302,7 +318,42 @@ fn foo() -> i32 {
302318 if true {
303319 42
304320 } else {
305- ()
321+ ${1:()}$0
322+ }
323+ }
324+ "# ,
325+ "Unwrap Option return type" ,
326+ ) ;
327+ }
328+
329+ #[ test]
330+ fn unwrap_option_return_type_multi_none ( ) {
331+ check_assist_by_label (
332+ unwrap_return_type,
333+ r#"
334+ //- minicore: option
335+ fn foo() -> Option<i3$02> {
336+ if false {
337+ return None;
338+ }
339+
340+ if true {
341+ Some(42)
342+ } else {
343+ None
344+ }
345+ }
346+ "# ,
347+ r#"
348+ fn foo() -> i32 {
349+ if false {
350+ return ${1:()};
351+ }
352+
353+ if true {
354+ 42
355+ } else {
356+ ${2:()}$0
306357 }
307358}
308359"# ,
0 commit comments