File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -1466,15 +1466,21 @@ and print_type_param ~state (param : Parsetree.core_type * Asttypes.variance)
14661466
14671467and print_record_declaration ?check_break_from_loc ?inline_record_definitions
14681468 ?record_loc ~state (lds : Parsetree.label_declaration list ) cmt_tbl =
1469+ let get_field_start_line (ld : Parsetree.label_declaration ) =
1470+ (* For spread fields (...), use the type location instead of pld_loc
1471+ because pld_loc may incorrectly include preceding whitespace *)
1472+ if ld.pld_name.txt = " ..." then ld.pld_type.ptyp_loc.loc_start.pos_lnum
1473+ else ld.pld_loc.loc_start.pos_lnum
1474+ in
14691475 let force_break =
14701476 match (check_break_from_loc, record_loc, lds) with
14711477 | Some loc , _ , _ -> loc.Location. loc_start.pos_lnum < loc.loc_end.pos_lnum
14721478 | None , Some loc , first :: _ ->
14731479 (* Check if first field is on a different line than the opening brace *)
1474- loc.loc_start.pos_lnum < first. Parsetree. pld_loc.loc_start.pos_lnum
1480+ loc.loc_start.pos_lnum < get_field_start_line first
14751481 | None , None , first :: _ ->
14761482 let last = List. hd (List. rev lds) in
1477- first.pld_loc.loc_start.pos_lnum < last.pld_loc.loc_end.pos_lnum
1483+ get_field_start_line first < last.pld_loc.loc_end.pos_lnum
14781484 | _ , _ , _ -> false
14791485 in
14801486 Doc. breakable_group ~force_break
You can’t perform that action at this time.
0 commit comments