@@ -197,6 +197,19 @@ fn cursor_at_trivial_match_arm_list(
197197 return Some ( ( ) ) ;
198198 }
199199
200+ // match x {
201+ // bar => baz,
202+ // $0
203+ // }
204+ if let Some ( last_arm) = match_arm_list. arms ( ) . last ( ) {
205+ let last_arm_range = last_arm. syntax ( ) . text_range ( ) ;
206+ let match_expr_range = match_expr. syntax ( ) . text_range ( ) ;
207+ if last_arm_range. end ( ) <= ctx. offset ( ) && ctx. offset ( ) < match_expr_range. end ( ) {
208+ cov_mark:: hit!( add_missing_match_arms_end_of_last_arm) ;
209+ return Some ( ( ) ) ;
210+ }
211+ }
212+
200213 // match { _$0 => {...} }
201214 let wild_pat = ctx. find_node_at_offset_with_descend :: < ast:: WildcardPat > ( ) ?;
202215 let arm = wild_pat. syntax ( ) . parent ( ) . and_then ( ast:: MatchArm :: cast) ?;
@@ -676,6 +689,41 @@ fn main() {
676689 ) ;
677690 }
678691
692+ #[ test]
693+ fn add_missing_match_arms_end_of_last_arm ( ) {
694+ cov_mark:: check!( add_missing_match_arms_end_of_last_arm) ;
695+ check_assist (
696+ add_missing_match_arms,
697+ r#"
698+ enum A { One, Two }
699+ enum B { One, Two }
700+
701+ fn main() {
702+ let a = A::One;
703+ let b = B::One;
704+ match (a, b) {
705+ (A::Two, B::One) => {},$0
706+ }
707+ }
708+ "# ,
709+ r#"
710+ enum A { One, Two }
711+ enum B { One, Two }
712+
713+ fn main() {
714+ let a = A::One;
715+ let b = B::One;
716+ match (a, b) {
717+ (A::Two, B::One) => {},
718+ $0(A::One, B::One) => todo!(),
719+ (A::One, B::Two) => todo!(),
720+ (A::Two, B::Two) => todo!(),
721+ }
722+ }
723+ "# ,
724+ ) ;
725+ }
726+
679727 #[ test]
680728 fn add_missing_match_arms_tuple_of_enum ( ) {
681729 check_assist (
0 commit comments