@@ -663,44 +663,48 @@ let get_list_expr (c : Conf.t) =
663663let get_array_expr (c : Conf.t ) =
664664 collection_expr c ~space_around: c.fmt_opts.space_around_arrays.v " [|" " |]"
665665
666- let box_pattern_docked (c : Conf.t ) ~ctx ~space_around opn cls k =
666+ let box_pattern_docked (c : Conf.t ) ~ctx ~space_around ~ pat opn cls k =
667667 let space = if space_around then 1 else 0 in
668668 let indent_opn, indent_cls =
669669 match (ctx, c.fmt_opts.break_separators.v) with
670670 | Ast. Exp {pexp_desc = Pexp_match _ | Pexp_try _ ; _} , `Before ->
671671 (String. length opn - 3 , 1 - String. length opn)
672672 | Ast. Exp {pexp_desc = Pexp_match _ | Pexp_try _ ; _} , `After -> (- 3 , 1 )
673- | Ast. Exp {pexp_desc = Pexp_let _ ; _} , _ -> (- 4 , 0 )
673+ | Ast. Exp {pexp_desc= Pexp_let ({pvbs_bindings; _}, _, _); _}, _
674+ when List. exists pvbs_bindings ~f: (fun b -> phys_equal b.pvb_pat pat)
675+ ->
676+ (- 4 , 0 )
674677 | _ -> (0 , 0 )
675678 in
676679 hvbox indent_opn
677680 (wrap (str opn) (str cls) (break space 2 $ k $ break space indent_cls))
678681
679- let get_record_pat (c : Conf.t ) ~ctx =
682+ let get_record_pat (c : Conf.t ) ~ctx pat =
680683 let params, _ = get_record_expr c in
681684 let box =
682685 if c.fmt_opts.dock_collection_brackets.v then
683686 box_pattern_docked c ~ctx
684- ~space_around: c.fmt_opts.space_around_records.v " {" " }"
687+ ~space_around: c.fmt_opts.space_around_records.v ~pat " {" " }"
685688 else params.box
686689 in
687690 {params with box}
688691
689- let collection_pat (c : Conf.t ) ~ctx ~space_around opn cls =
692+ let collection_pat (c : Conf.t ) ~ctx ~space_around ~ pat opn cls =
690693 let params = collection_expr c ~space_around opn cls in
691694 let box =
692695 if c.fmt_opts.dock_collection_brackets.v then
693- box_collec c 0 >> box_pattern_docked c ~ctx ~space_around opn cls
696+ box_collec c 0 >> box_pattern_docked c ~ctx ~space_around ~pat opn cls
694697 else params.box
695698 in
696699 {params with box}
697700
698- let get_list_pat (c : Conf.t ) ~ctx =
699- collection_pat c ~ctx ~space_around: c.fmt_opts.space_around_lists.v " [" " ]"
701+ let get_list_pat (c : Conf.t ) ~ctx pat =
702+ collection_pat c ~ctx ~space_around: c.fmt_opts.space_around_lists.v ~pat
703+ " [" " ]"
700704
701- let get_array_pat (c : Conf.t ) ~ctx =
702- collection_pat c ~ctx ~space_around: c.fmt_opts.space_around_arrays.v " [| "
703- " |]"
705+ let get_array_pat (c : Conf.t ) ~ctx pat =
706+ collection_pat c ~ctx ~space_around: c.fmt_opts.space_around_arrays.v ~pat
707+ " [| " " |]"
704708
705709type if_then_else =
706710 { box_branch : Fmt .t -> Fmt .t
0 commit comments