@@ -41,7 +41,7 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext) ->
41
41
let match_arm_list = match_expr. match_arm_list ( ) ?;
42
42
let target_range : TextRange ;
43
43
44
- if ! cursor_inside_simple_match_arm_list ( & ctx, & match_expr, & match_arm_list) {
44
+ if let None = cursor_inside_simple_match_arm_list ( & ctx, & match_expr, & match_arm_list) {
45
45
target_range = TextRange :: new (
46
46
ctx. sema . original_range ( match_expr. syntax ( ) ) . range . start ( ) ,
47
47
ctx. sema . original_range ( match_arm_list. syntax ( ) ) . range . start ( ) ,
@@ -192,12 +192,20 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext) ->
192
192
)
193
193
}
194
194
195
- fn cursor_inside_simple_match_arm_list ( ctx : & AssistContext , match_expr : & MatchExpr , match_arm_list : & MatchArmList ) -> bool {
196
- // println!("---\n{:#?}\n{:#?}\n---", match_expr, match_arm_list);
195
+ fn cursor_inside_simple_match_arm_list ( ctx : & AssistContext , match_expr : & MatchExpr , match_arm_list : & MatchArmList ) -> Option < ( ) > {
196
+ println ! ( "---\n {:#?}\n {:#?}\n ---" , match_expr, match_arm_list) ;
197
197
if match_arm_list. arms ( ) . next ( ) == None {
198
- return true ;
198
+ return Some ( ( ) ) ;
199
199
}
200
- false
200
+
201
+ let wild_pat = ctx. find_node_at_offset_with_descend :: < ast:: WildcardPat > ( ) ?;
202
+ let arm = wild_pat. syntax ( ) . parent ( ) . and_then ( ast:: MatchArm :: cast) ?;
203
+ let arm_match_expr = arm. syntax ( ) . ancestors ( ) . nth ( 2 ) . and_then ( ast:: MatchExpr :: cast) ?;
204
+ if arm_match_expr == * match_expr {
205
+ return Some ( ( ) )
206
+ }
207
+
208
+ None
201
209
}
202
210
203
211
fn is_variant_missing ( existing_pats : & [ Pat ] , var : & Pat ) -> bool {
0 commit comments