@@ -4583,6 +4583,18 @@ and get_line_sep_for_jsx_children (children : Parsetree.jsx_children) =
45834583
45844584and print_jsx_children ~state (children : Parsetree.jsx_children ) cmt_tbl =
45854585 let open Parsetree in
4586+ let get_loc (expr : Parsetree.expression ) =
4587+ let braces =
4588+ expr.pexp_attributes
4589+ |> List. find_map (fun (attr , _ ) ->
4590+ match attr with
4591+ | {Location. txt = "res.braces" ; loc} -> Some loc
4592+ | _ -> None )
4593+ in
4594+ match braces with
4595+ | None -> expr.pexp_loc
4596+ | Some loc -> loc
4597+ in
45864598 let sep = get_line_sep_for_jsx_children children in
45874599 let print_expr (expr : Parsetree.expression ) =
45884600 let leading_line_comment_present =
@@ -4598,7 +4610,7 @@ and print_jsx_children ~state (children : Parsetree.jsx_children) cmt_tbl =
45984610 else Doc. concat [Doc. lbrace; inner_doc; Doc. rbrace]
45994611 in
46004612 match Parens. jsx_child_expr expr with
4601- | Nothing -> expr_doc
4613+ | Nothing -> print_comments expr_doc cmt_tbl (get_loc expr)
46024614 | Parenthesized -> add_parens_or_braces expr_doc
46034615 | Braced braces_loc ->
46044616 print_comments (add_parens_or_braces expr_doc) cmt_tbl braces_loc
@@ -4607,19 +4619,6 @@ and print_jsx_children ~state (children : Parsetree.jsx_children) cmt_tbl =
46074619 | JSXChildrenItems [] -> Doc. nil
46084620 | JSXChildrenSpreading child -> Doc. concat [Doc. dotdotdot; print_expr child]
46094621 | JSXChildrenItems children ->
4610- let get_loc (expr : Parsetree.expression ) =
4611- let braces =
4612- expr.pexp_attributes
4613- |> List. find_map (fun (attr , _ ) ->
4614- match attr with
4615- | {Location. txt = "res.braces" ; loc} -> Some loc
4616- | _ -> None )
4617- in
4618- match braces with
4619- | None -> expr.pexp_loc
4620- | Some loc -> loc
4621- in
4622-
46234622 let rec visit acc children =
46244623 match children with
46254624 | [] -> acc
0 commit comments