@@ -715,20 +715,15 @@ and fmt_arrow_param c ctx {pap_label= lI; pap_loc= locI; pap_type= tI} =
715715 in
716716 hvbox 0 (Cmts. fmt_before c locI $ arg)
717717
718- (* * Format [Ptyp_arrow]. [separator_len] is the length of prologue that might
719- be aligned to . [parent_has_parens] is used to align arrows to
720- parentheses. *)
721- and fmt_arrow_type c ~ctx ?separator_len ~parens ~parent_has_parens args
722- fmt_ret_typ =
718+ (* * Format [Ptyp_arrow]. [indent] can be used to override the indentation
719+ added for the break-separators option . [parent_has_parens] is used to
720+ align arrows to parentheses. *)
721+ and fmt_arrow_type c ~ctx ?indent ~parens ~parent_has_parens args fmt_ret_typ
722+ =
723723 let indent =
724- match separator_len with
725- | Some separator_len when c.conf.fmt_opts.ocp_indent_compat.v ->
726- let indent =
727- if Poly. (c.conf.fmt_opts.break_separators.v = `Before ) then 2
728- else 0
729- in
730- fits_breaks " " (String. make (Int. max 1 (indent - separator_len)) ' ' )
731- | _ ->
724+ match indent with
725+ | Some k -> k
726+ | None ->
732727 fmt_if_k
733728 Poly. (c.conf.fmt_opts.break_separators.v = `Before )
734729 (fmt_or_k c.conf.fmt_opts.ocp_indent_compat.v (fits_breaks " " " " )
@@ -797,9 +792,20 @@ and fmt_core_type c ?(box = true) ?pro ?(pro_space = true) ?constraint_ctx
797792 | Ptyp_arrow (args , ret_typ ) ->
798793 Cmts. relocate c.cmts ~src: ptyp_loc
799794 ~before: (List. hd_exn args).pap_type.ptyp_loc ~after: ret_typ.ptyp_loc ;
800- let separator_len = Option. map ~f: String. length pro in
795+ let indent =
796+ match pro with
797+ | Some pro when c.conf.fmt_opts.ocp_indent_compat.v ->
798+ let indent =
799+ if Poly. (c.conf.fmt_opts.break_separators.v = `Before ) then 2
800+ else 0
801+ in
802+ Some
803+ (fits_breaks " "
804+ (String. make (Int. max 1 (indent - String. length pro)) ' ' ) )
805+ | _ -> None
806+ in
801807 let fmt_ret_typ = fmt_core_type c (sub_typ ~ctx ret_typ) in
802- fmt_arrow_type c ~ctx ?separator_len ~parens: parenze_constraint_ctx
808+ fmt_arrow_type c ~ctx ?indent ~parens: parenze_constraint_ctx
803809 ~parent_has_parens: parens args fmt_ret_typ
804810 | Ptyp_constr (lid , [] ) -> fmt_longident_loc c lid
805811 | Ptyp_constr (lid , [t1 ]) ->
0 commit comments