@@ -340,7 +340,8 @@ let print_list ~get_loc ~nodes ~print ?(force_break = false) t =
340340 in
341341 Doc. breakable_group ~force_break docs
342342
343- let print_listi ~get_loc ~nodes ~print ?(force_break = false ) t =
343+ let print_listi ~get_loc ~nodes ~print ?(ignore_empty_lines = false )
344+ ?(force_break = false ) t =
344345 let rec loop i (prev_loc : Location.t ) acc nodes =
345346 match nodes with
346347 | [] -> (prev_loc, Doc. concat (List. rev acc))
@@ -352,8 +353,10 @@ let print_listi ~get_loc ~nodes ~print ?(force_break = false) t =
352353 | Some comment -> (Comment. loc comment).loc_start
353354 in
354355 let sep =
355- if start_pos.pos_lnum - prev_loc.loc_end.pos_lnum > 1 then
356- Doc. concat [Doc. hard_line; Doc. hard_line]
356+ if
357+ start_pos.pos_lnum - prev_loc.loc_end.pos_lnum > 1
358+ && not ignore_empty_lines
359+ then Doc. concat [Doc. hard_line; Doc. hard_line]
357360 else Doc. line
358361 in
359362 let doc = print_comments (print node t i) t loc in
@@ -1542,18 +1545,22 @@ and print_constructor_declarations ~state ~private_flag
15421545 ~print: (fun cd cmt_tbl i ->
15431546 let doc = print_constructor_declaration2 ~state i cd cmt_tbl in
15441547 print_comments doc cmt_tbl cd.Parsetree. pcd_loc)
1545- ~force_break cmt_tbl
1548+ ~force_break cmt_tbl ~ignore_empty_lines: true
15461549 in
15471550 Doc. breakable_group ~force_break
15481551 (Doc. indent (Doc. concat [Doc. line; private_flag; rows]))
15491552
15501553and print_constructor_declaration2 ~state i
15511554 (cd : Parsetree.constructor_declaration ) cmt_tbl =
1552- let comment_attrs, attrs = ParsetreeViewer. partition_doc_comment_attributes cd.pcd_attributes in
1555+ let comment_attrs, attrs =
1556+ ParsetreeViewer. partition_doc_comment_attributes cd.pcd_attributes
1557+ in
15531558 let comment_doc =
15541559 match comment_attrs with
15551560 | [] -> Doc. nil
1556- | comment_attrs -> print_doc_comments ~sep: Doc. hard_line ~state cmt_tbl comment_attrs in
1561+ | comment_attrs ->
1562+ print_doc_comments ~sep: Doc. hard_line ~state cmt_tbl comment_attrs
1563+ in
15571564 let attrs = print_attributes ~state attrs cmt_tbl in
15581565 let is_dot_dot_dot = cd.pcd_name.txt = " ..." in
15591566 let bar =
0 commit comments