File tree Expand file tree Collapse file tree 2 files changed +40
-5
lines changed Expand file tree Collapse file tree 2 files changed +40
-5
lines changed Original file line number Diff line number Diff line change @@ -4035,15 +4035,30 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl =
4035
4035
and print_belt_array_concat_apply ~state sub_lists cmt_tbl =
4036
4036
let make_spread_doc comma_before_spread = function
4037
4037
| Some expr ->
4038
+ (* Extract leading comments before dotdotdot *)
4039
+ let leading_comments_doc =
4040
+ print_leading_comments Doc. nil cmt_tbl.CommentTable. leading
4041
+ expr.Parsetree. pexp_loc
4042
+ in
4043
+ (* Print expression without leading comments (they're already extracted) *)
4044
+ let expr_doc =
4045
+ let doc = print_expression ~state expr cmt_tbl in
4046
+ match Parens. expr expr with
4047
+ | Parens. Parenthesized -> add_parens doc
4048
+ | Braced braces -> print_braces doc expr braces
4049
+ | Nothing -> doc
4050
+ in
4051
+ (* Print trailing comments with the expression *)
4052
+ let expr_with_trailing_comments =
4053
+ print_trailing_comments expr_doc cmt_tbl.CommentTable. trailing
4054
+ expr.Parsetree. pexp_loc
4055
+ in
4038
4056
Doc. concat
4039
4057
[
4040
4058
comma_before_spread;
4059
+ leading_comments_doc;
4041
4060
Doc. dotdotdot;
4042
- (let doc = print_expression_with_comments ~state expr cmt_tbl in
4043
- match Parens. expr expr with
4044
- | Parens. Parenthesized -> add_parens doc
4045
- | Braced braces -> print_braces doc expr braces
4046
- | Nothing -> doc);
4061
+ expr_with_trailing_comments;
4047
4062
]
4048
4063
| None -> Doc. nil
4049
4064
in
Original file line number Diff line number Diff line change @@ -32,3 +32,23 @@ let _ = [
32
32
// comment 2
33
33
b , c
34
34
]
35
+
36
+ let _ = [
37
+ // comment 0
38
+ ... xs ,
39
+ // comment 1
40
+ a ,
41
+ // comment 2
42
+ b , c
43
+ ]
44
+
45
+ let _ = [
46
+ // comment 0
47
+ ... xs ,
48
+ // comment 1
49
+ a ,
50
+ // comment 2
51
+ ... ys ,
52
+ // comment 3
53
+ b , c
54
+ ]
You can’t perform that action at this time.
0 commit comments