@@ -1472,7 +1472,7 @@ fn parse_arrow_func_expr<'a>(node: &'a ArrowExpr, context: &mut Context<'a>) ->
1472
1472
items. push_str ( " =>" ) ;
1473
1473
1474
1474
let parsed_body = parse_node ( node. body . into ( ) , context) ;
1475
- let parsed_body = if use_new_line_group_for_arrow_body ( node) {
1475
+ let parsed_body = if use_new_line_group_for_arrow_body ( node, context ) {
1476
1476
new_line_group ( parsed_body)
1477
1477
} else {
1478
1478
parsed_body
@@ -1499,7 +1499,7 @@ fn parse_arrow_func_expr<'a>(node: &'a ArrowExpr, context: &mut Context<'a>) ->
1499
1499
let end_body_info = Info :: new ( "endBody" ) ;
1500
1500
items. push_info ( start_body_info) ;
1501
1501
1502
- if should_not_newline_after_arrow ( & node. body ) {
1502
+ if should_not_newline_after_arrow ( & node. body , context ) {
1503
1503
items. push_str ( " " ) ;
1504
1504
} else {
1505
1505
items. push_condition ( conditions:: if_above_width_or (
@@ -1521,13 +1521,13 @@ fn parse_arrow_func_expr<'a>(node: &'a ArrowExpr, context: &mut Context<'a>) ->
1521
1521
1522
1522
return items;
1523
1523
1524
- fn should_not_newline_after_arrow ( body : & BlockStmtOrExpr ) -> bool {
1524
+ fn should_not_newline_after_arrow ( body : & BlockStmtOrExpr , context : & Context ) -> bool {
1525
1525
match body {
1526
1526
BlockStmtOrExpr :: BlockStmt ( _) => true ,
1527
1527
BlockStmtOrExpr :: Expr ( expr) => match expr {
1528
1528
Expr :: Paren ( _) | Expr :: Array ( _) => true ,
1529
1529
Expr :: Tpl ( tpl) => tpl. quasis [ 0 ] . raw . value ( ) . starts_with ( |c : char | c == '\n' || c == '\r' ) ,
1530
- _ => false ,
1530
+ _ => is_jsx_paren_expr_handled_node ( & expr . into ( ) , context ) ,
1531
1531
} ,
1532
1532
}
1533
1533
}
@@ -2285,16 +2285,16 @@ fn parse_paren_expr<'a>(node: &'a ParenExpr, context: &mut Context<'a>) -> Print
2285
2285
) )
2286
2286
. into ( ) ;
2287
2287
2288
- return if get_use_new_line_group ( node) {
2288
+ return if get_use_new_line_group ( node, context ) {
2289
2289
new_line_group ( parsed_items)
2290
2290
} else {
2291
2291
parsed_items
2292
2292
} ;
2293
2293
2294
- fn get_use_new_line_group ( node : & ParenExpr ) -> bool {
2294
+ fn get_use_new_line_group ( node : & ParenExpr , context : & Context ) -> bool {
2295
2295
if let Node :: ArrowExpr ( arrow_expr) = node. parent ( ) {
2296
2296
debug_assert ! ( arrow_expr. body. lo( ) == node. lo( ) ) ;
2297
- use_new_line_group_for_arrow_body ( arrow_expr)
2297
+ use_new_line_group_for_arrow_body ( arrow_expr, context )
2298
2298
} else {
2299
2299
true
2300
2300
}
@@ -8241,11 +8241,14 @@ fn assert_has_op<'a>(op: &str, op_token: Option<&TokenAndSpan>, context: &mut Co
8241
8241
}
8242
8242
}
8243
8243
8244
- fn use_new_line_group_for_arrow_body ( arrow_expr : & ArrowExpr ) -> bool {
8244
+ fn use_new_line_group_for_arrow_body ( arrow_expr : & ArrowExpr , context : & Context ) -> bool {
8245
8245
match & arrow_expr. body {
8246
- BlockStmtOrExpr :: Expr ( Expr :: Paren ( paren) ) => match paren. expr {
8247
- Expr :: Object ( _) => false ,
8248
- _ => true ,
8246
+ BlockStmtOrExpr :: Expr ( expr) => match expr {
8247
+ Expr :: Paren ( paren) => match paren. expr {
8248
+ Expr :: Object ( _) => false ,
8249
+ _ => !is_jsx_paren_expr_handled_node ( & paren. expr . into ( ) , context) ,
8250
+ } ,
8251
+ _ => !is_jsx_paren_expr_handled_node ( & expr. into ( ) , context) ,
8249
8252
} ,
8250
8253
_ => true ,
8251
8254
}
0 commit comments