Skip to content

Commit a7a48e5

Browse files
committed
Handle case with comments
1 parent 1ca442a commit a7a48e5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler/syntax/src/res_printer.ml

+7-2
Original file line numberDiff line numberDiff line change
@@ -4448,10 +4448,15 @@ and print_jsx_children ~state (children_expr : Parsetree.expression) ~sep
44484448
| Braced braces_loc ->
44494449
print_comments (add_parens_or_braces expr_doc) cmt_tbl braces_loc
44504450
in
4451+
let get_first_leading_comment loc =
4452+
match get_first_leading_comment cmt_tbl loc with
4453+
| None -> loc
4454+
| Some comment -> Comment.loc comment
4455+
in
44514456
let get_loc expr =
44524457
match ParsetreeViewer.process_braces_attr expr with
4453-
| None, _ -> expr.pexp_loc
4454-
| Some ({loc}, _), _ -> loc
4458+
| None, _ -> get_first_leading_comment expr.pexp_loc
4459+
| Some ({loc}, _), _ -> get_first_leading_comment loc
44554460
in
44564461
let rec loop prev acc exprs =
44574462
match exprs with

0 commit comments

Comments
 (0)