@@ -4427,7 +4427,7 @@ and print_jsx_fragment ~state expr cmt_tbl =
4427
4427
and print_jsx_children ~state (children_expr : Parsetree.expression ) ~sep
4428
4428
cmt_tbl =
4429
4429
match children_expr.pexp_desc with
4430
- | Pexp_construct ({loc; txt = Longident. Lident "::" } , _ ) ->
4430
+ | Pexp_construct ({txt = Longident. Lident "::" } , _ ) ->
4431
4431
let children, _ = ParsetreeViewer. collect_list_expressions children_expr in
4432
4432
let print_expr (expr : Parsetree.expression ) =
4433
4433
let leading_line_comment_present =
@@ -4448,41 +4448,26 @@ and print_jsx_children ~state (children_expr : Parsetree.expression) ~sep
4448
4448
| Braced braces_loc ->
4449
4449
print_comments (add_parens_or_braces expr_doc) cmt_tbl braces_loc
4450
4450
in
4451
+ let get_loc expr =
4452
+ match ParsetreeViewer. process_braces_attr expr with
4453
+ | None , _ -> expr.pexp_loc
4454
+ | Some ({loc} , _ ), _ -> loc
4455
+ in
4451
4456
let rec loop prev acc exprs =
4452
4457
match exprs with
4453
4458
| [] -> List. rev acc
4454
- | ({Parsetree. pexp_loc = current_loc } as expr ) :: tails ->
4459
+ | expr :: tails ->
4460
+ let start_loc = (get_loc expr).loc_start.pos_lnum in
4461
+ let end_loc = (get_loc prev).loc_end.pos_lnum in
4462
+ let expr_doc = print_expr expr in
4455
4463
let docs =
4456
- if current_loc.loc_start.pos_lnum - prev.Warnings. loc_end.pos_lnum > 1
4457
- then
4458
- let expr = print_expr expr in
4459
- let acc = Doc. concat [Doc. hard_line; expr] :: acc in
4460
- acc
4461
- else
4462
- let expr = print_expr expr in
4463
- let acc = expr :: acc in
4464
- acc
4465
- in
4466
- (* adjust for braces when we forward the current_loc to the recursion *)
4467
- let current_loc =
4468
- match expr with
4469
- | {Parsetree. pexp_loc = loc}
4470
- when loc.loc_start.pos_lnum == loc.loc_end.pos_lnum ->
4471
- current_loc
4472
- | _ when ParsetreeViewer. is_braced_expr expr ->
4473
- {
4474
- current_loc with
4475
- loc_end =
4476
- {
4477
- current_loc.loc_end with
4478
- pos_lnum = current_loc.loc_end.pos_lnum + 1 ;
4479
- };
4480
- }
4481
- | _ -> current_loc
4464
+ if start_loc - end_loc > 1 then
4465
+ Doc. concat [Doc. hard_line; expr_doc] :: acc
4466
+ else expr_doc :: acc
4482
4467
in
4483
- loop current_loc docs tails
4468
+ loop expr docs tails
4484
4469
in
4485
- let docs = loop loc [] children in
4470
+ let docs = loop children_expr [] children in
4486
4471
Doc. group (Doc. join ~sep docs)
4487
4472
| _ ->
4488
4473
let leading_line_comment_present =
0 commit comments