@@ -70,8 +70,8 @@ pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext<'_>) -> Op
70
70
}
71
71
72
72
let node = ctx. covering_element ( ) ;
73
- if node. kind ( ) == SyntaxKind :: L_CURLY || node . kind ( ) == SyntaxKind :: R_CURLY {
74
- cov_mark:: hit!( extract_function_in_curly_bracket_is_not_applicable ) ;
73
+ if matches ! ( node. kind( ) , T ! [ '{' ] | T ! [ '}' ] | T ! [ '(' ] | T ! [ ')' ] | T ! [ '[' ] | T ! [ ']' ] ) {
74
+ cov_mark:: hit!( extract_function_in_braces_is_not_applicable ) ;
75
75
return None ;
76
76
}
77
77
@@ -5808,13 +5808,37 @@ fn $0fun_name() -> ControlFlow<()> {
5808
5808
5809
5809
#[ test]
5810
5810
fn in_left_curly_is_not_applicable ( ) {
5811
- cov_mark:: check!( extract_function_in_curly_bracket_is_not_applicable ) ;
5812
- check_assist_not_applicable ( extract_function, r"fn foo() { $0}$0 " ) ;
5811
+ cov_mark:: check!( extract_function_in_braces_is_not_applicable ) ;
5812
+ check_assist_not_applicable ( extract_function, r"fn foo() { $0}$0" ) ;
5813
5813
}
5814
5814
5815
5815
#[ test]
5816
5816
fn in_right_curly_is_not_applicable ( ) {
5817
- cov_mark:: check!( extract_function_in_curly_bracket_is_not_applicable) ;
5818
- check_assist_not_applicable ( extract_function, r"fn foo() $0{$0 } " ) ;
5817
+ cov_mark:: check!( extract_function_in_braces_is_not_applicable) ;
5818
+ check_assist_not_applicable ( extract_function, r"fn foo() $0{$0 }" ) ;
5819
+ }
5820
+
5821
+ #[ test]
5822
+ fn in_left_paren_is_not_applicable ( ) {
5823
+ cov_mark:: check!( extract_function_in_braces_is_not_applicable) ;
5824
+ check_assist_not_applicable ( extract_function, r"fn foo( $0)$0 { }" ) ;
5825
+ }
5826
+
5827
+ #[ test]
5828
+ fn in_right_paren_is_not_applicable ( ) {
5829
+ cov_mark:: check!( extract_function_in_braces_is_not_applicable) ;
5830
+ check_assist_not_applicable ( extract_function, r"fn foo $0($0 ) { }" ) ;
5831
+ }
5832
+
5833
+ #[ test]
5834
+ fn in_left_brack_is_not_applicable ( ) {
5835
+ cov_mark:: check!( extract_function_in_braces_is_not_applicable) ;
5836
+ check_assist_not_applicable ( extract_function, r"fn foo(arr: &mut [i32$0]$0) {}" ) ;
5837
+ }
5838
+
5839
+ #[ test]
5840
+ fn in_right_brack_is_not_applicable ( ) {
5841
+ cov_mark:: check!( extract_function_in_braces_is_not_applicable) ;
5842
+ check_assist_not_applicable ( extract_function, r"fn foo(arr: &mut $0[$0i32]) {}" ) ;
5819
5843
}
5820
5844
}
0 commit comments