@@ -1641,7 +1641,6 @@ fn parse_await_expr<'a>(node: &'a AwaitExpr, context: &mut Context<'a>) -> Print
1641
1641
}
1642
1642
1643
1643
fn parse_binary_expr < ' a > ( node : & ' a BinExpr , context : & mut Context < ' a > ) -> PrintItems {
1644
- // todo: use a simplified version for nodes that don't need the complexity (for performance reasons)
1645
1644
let mut items = PrintItems :: new ( ) ;
1646
1645
let flattened_binary_expr = get_flattened_bin_expr ( node, context) ;
1647
1646
// println!("Bin expr: {:?}", flattened_binary_expr.iter().map(|x| x.expr.text(context)).collect::<Vec<_>>());
@@ -1795,8 +1794,14 @@ fn parse_binary_expr<'a>(node: &'a BinExpr, context: &mut Context<'a>) -> PrintI
1795
1794
items
1796
1795
} ) ) ;
1797
1796
1797
+ let items = if should_newline_group_bin_item_expr ( & bin_expr_item. expr , context) {
1798
+ parser_helpers:: new_line_group ( items)
1799
+ } else {
1800
+ items
1801
+ } ;
1802
+
1798
1803
parsed_nodes. push ( parser_helpers:: ParsedValue {
1799
- items : parser_helpers :: new_line_group ( items ) ,
1804
+ items,
1800
1805
lines_span,
1801
1806
allow_inline_multi_line : true ,
1802
1807
allow_inline_single_line : true ,
@@ -1872,13 +1877,26 @@ fn parse_binary_expr<'a>(node: &'a BinExpr, context: &mut Context<'a>) -> PrintI
1872
1877
items
1873
1878
}
1874
1879
1875
- fn get_use_space_surrounding_operator ( op : & BinaryOp , context : & mut Context ) -> bool {
1880
+ fn get_use_space_surrounding_operator ( op : & BinaryOp , context : & Context ) -> bool {
1876
1881
if op. is_bitwise_or_arithmetic ( ) {
1877
1882
context. config . binary_expression_space_surrounding_bitwise_and_arithmetic_operator
1878
1883
} else {
1879
1884
true
1880
1885
}
1881
1886
}
1887
+
1888
+ fn should_newline_group_bin_item_expr ( node : & Node , context : & Context ) -> bool {
1889
+ if let Some ( node) = node. to :: < ParenExpr > ( ) {
1890
+ return should_newline_group_bin_item_expr ( & node. expr . into ( ) , context) ;
1891
+ }
1892
+
1893
+ if is_jsx_paren_expr_handled_node ( node, context) {
1894
+ // prefer using the possible newline at the start of the element
1895
+ return false ;
1896
+ }
1897
+
1898
+ true
1899
+ }
1882
1900
}
1883
1901
1884
1902
fn parse_call_expr < ' a > ( node : & ' a CallExpr , context : & mut Context < ' a > ) -> PrintItems {
0 commit comments