File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2562,7 +2562,7 @@ and fmt_expression c ?(box = true) ?(pro = noop) ?eol ?parens
25622562 let cmts_after_kw, raw_cmts_after_kw =
25632563 if Cmts. has_after c.cmts keyword_loc then
25642564 if
2565- Params. needs_raw_cmts_after_kw
2565+ Params. is_special_or_nested_special_beginend
25662566 xbch.ast.pexp_desc
25672567 then
25682568 ( None
Original file line number Diff line number Diff line change @@ -512,15 +512,9 @@ let is_special_beginend exp =
512512 | Pexp_match _ | Pexp_try _ | Pexp_function _ | Pexp_ifthenelse _ -> true
513513 | _ -> false
514514
515- let needs_raw_cmts_after_kw = function
516- | Pexp_beginend
517- ( { pexp_desc=
518- Pexp_match _ | Pexp_try _ | Pexp_function _ | Pexp_ifthenelse _
519- ; _ }
520- , _ )
521- | Pexp_match _ | Pexp_try _ | Pexp_function _ | Pexp_ifthenelse _ ->
522- true
523- | _ -> false
515+ let is_special_or_nested_special_beginend = function
516+ | Pexp_beginend ({pexp_desc; _} , _ ) -> is_special_beginend pexp_desc
517+ | exp -> is_special_beginend exp
524518
525519let raw_cmts_branch_pro (c : Conf.t ) cmts =
526520 match c.fmt_opts.if_then_else.v with
@@ -942,7 +936,7 @@ let get_if_then_else (c : Conf.t) ~cmts_before_opt ~pro ~first ~last
942936 (not has_beginend) && (not parens_bch)
943937 && (not (Location. is_single_line expr_loc c.fmt_opts.margin.v))
944938 && (not has_cmts_after_kw)
945- && needs_raw_cmts_after_kw xbch.ast.pexp_desc
939+ && is_special_or_nested_special_beginend xbch.ast.pexp_desc
946940 then
947941 match cmts_before_opt xbch.ast.pexp_loc with
948942 | Some cmts -> break 1000 0 $ cmts $ break 1000 0
Original file line number Diff line number Diff line change @@ -237,9 +237,9 @@ val get_if_then_else :
237237 -> if_then_else
238238(* * [cmts_before_opt] return the comment before the given location with no breaks around it. *)
239239
240- val needs_raw_cmts_after_kw : expression_desc -> bool
241- (* * [needs_raw_cmts_after_kw desc ] returns [true] when comments after the
242- keyword should be extracted without breaks (raw) to prevent oscillation
240+ val is_special_or_nested_special_beginend : expression_desc -> bool
241+ (* * [is_special_or_nested_special_beginend ] returns [true] when comments after
242+ the keyword should be extracted without breaks (raw) to prevent oscillation
243243 between "after keyword" and "before expression" placements. *)
244244
245245val raw_cmts_branch_pro : Conf .t -> Fmt .t -> Fmt .t
You can’t perform that action at this time.
0 commit comments