diff --git a/CHANGES.md b/CHANGES.md index 797002d038..997b932ade 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,10 @@ profile. This started with version 0.26.0. ### Fixed +- Fix formatting oscillation with `if-then-else=fit-or-vertical` and + `begin...end`. + (#2800, @MisterDA) + - Fix instability on long `if-then-else` with `if-then-else=fit-or-vertical` (#2797, @MisterDA) diff --git a/lib/Fmt_ast.ml b/lib/Fmt_ast.ml index 62ecceced4..453f6658a3 100644 --- a/lib/Fmt_ast.ml +++ b/lib/Fmt_ast.ml @@ -2559,10 +2559,18 @@ and fmt_expression c ?(box = true) ?(pro = noop) ?eol ?parens let cmts_before_kw = Cmts.fmt_before c keyword_loc in - let cmts_after_kw = + let cmts_after_kw, raw_cmts_after_kw = if Cmts.has_after c.cmts keyword_loc then - Some (Cmts.fmt_after c keyword_loc) - else None + if + Params.needs_raw_cmts_after_kw + xbch.ast.pexp_desc + then + ( None + , Some + (Cmts.fmt_after ~pro:noop ~epi:noop c + keyword_loc ) ) + else (Some (Cmts.fmt_after c keyword_loc), None) + else (None, None) in let cmts_before_opt loc = if Cmts.has_before c.cmts loc then @@ -2582,6 +2590,12 @@ and fmt_expression c ?(box = true) ?(pro = noop) ?eol ?parens ~fmt_cond:(fmt_expression ~box:false c) ~cmts_before_kw ~cmts_after_kw in + let branch_pro = + match raw_cmts_after_kw with + | Some cmts -> + Params.raw_cmts_branch_pro c.conf cmts + | None -> p.branch_pro + in let wrap_beginend = match p.beginend_loc with | Some loc -> Cmts.fmt c loc @@ -2591,7 +2605,7 @@ and fmt_expression c ?(box = true) ?(pro = noop) ?eol ?parens p.box_branch ( p.cond $ p.box_keyword_and_expr - ( p.branch_pro + ( branch_pro $ wrap_beginend (p.wrap_parens ( fmt_expression c ?box:p.box_expr diff --git a/lib/Params.ml b/lib/Params.ml index 7a7fc5933e..35ccf6167b 100644 --- a/lib/Params.ml +++ b/lib/Params.ml @@ -512,6 +512,21 @@ let is_special_beginend exp = | Pexp_match _ | Pexp_try _ | Pexp_function _ | Pexp_ifthenelse _ -> true | _ -> false +let needs_raw_cmts_after_kw = function + | Pexp_beginend + ( { pexp_desc= + Pexp_match _ | Pexp_try _ | Pexp_function _ | Pexp_ifthenelse _ + ; _ } + , _ ) + |Pexp_match _ | Pexp_try _ | Pexp_function _ | Pexp_ifthenelse _ -> + true + | _ -> false + +let raw_cmts_branch_pro (c : Conf.t) cmts = + match c.fmt_opts.if_then_else.v with + | `Compact -> break 1000 0 $ cmts $ break 1000 0 + | _ -> break 1000 2 $ cmts + type cases = { leading_space: Fmt.t ; bar: Fmt.t @@ -922,10 +937,29 @@ let get_if_then_else (c : Conf.t) ~cmts_before_opt ~pro ~first ~last in match c.fmt_opts.if_then_else.v with | `Compact -> + let branch_pro_with_cmts = + if + (not has_beginend) && (not parens_bch) + && (not (Location.is_single_line expr_loc c.fmt_opts.margin.v)) + && (not has_cmts_after_kw) + && needs_raw_cmts_after_kw xbch.ast.pexp_desc + then + match cmts_before_opt xbch.ast.pexp_loc with + | Some cmts -> break 1000 0 $ cmts $ break 1000 0 + | None -> ( + match xbch.ast.pexp_desc with + | Pexp_beginend ({pexp_loc; pexp_desc; _}, _) + when is_special_beginend pexp_desc -> ( + match cmts_before_opt pexp_loc with + | Some cmts -> break 1000 0 $ cmts $ break 1000 0 + | None -> branch_pro ~indent:0 () ) + | _ -> branch_pro ~indent:0 () ) + else branch_pro ~indent:0 () + in { box_branch= hovbox ~name:"Params.get_if_then_else `Compact" 2 ; cond= cond () ; box_keyword_and_expr= Fn.id - ; branch_pro= branch_pro ~indent:0 () + ; branch_pro= branch_pro_with_cmts ; wrap_parens= wrap_parens ~wrap_breaks: @@ -954,6 +988,24 @@ let get_if_then_else (c : Conf.t) ~cmts_before_opt ~pro ~first ~last ; space_between_branches= fmt_if (has_beginend || parens_bch) (str " ") } | `Fit_or_vertical -> + let branch_pro_with_cmts = + if + (not has_beginend) + && (not (Location.is_single_line expr_loc c.fmt_opts.margin.v)) + && not has_cmts_after_kw + then + match cmts_before_opt xbch.ast.pexp_loc with + | Some cmts -> break 1000 2 $ cmts + | None -> ( + match xbch.ast.pexp_desc with + | Pexp_beginend ({pexp_loc; pexp_desc; _}, _) + when is_special_beginend pexp_desc -> ( + match cmts_before_opt pexp_loc with + | Some cmts -> break 1000 2 $ cmts + | None -> branch_pro ~begin_end_offset:0 () ) + | _ -> branch_pro ~begin_end_offset:0 () ) + else branch_pro ~begin_end_offset:0 () + in { box_branch= hovbox ( match imd with @@ -961,15 +1013,7 @@ let get_if_then_else (c : Conf.t) ~cmts_before_opt ~pro ~first ~last | _ -> 0 ) ; cond= cond () ; box_keyword_and_expr= Fn.id - ; branch_pro= - ( if - (not has_beginend) && (not has_cmts_after_kw) - && not (Location.is_single_line expr_loc c.fmt_opts.margin.v) - then - match cmts_before_opt xbch.ast.pexp_loc with - | Some cmts -> break 1000 2 $ cmts - | None -> branch_pro ~begin_end_offset:0 () - else branch_pro ~begin_end_offset:0 () ) + ; branch_pro= branch_pro_with_cmts ; wrap_parens= wrap_parens ~wrap_breaks: diff --git a/lib/Params.mli b/lib/Params.mli index c79466df44..ad257be66b 100644 --- a/lib/Params.mli +++ b/lib/Params.mli @@ -237,6 +237,16 @@ val get_if_then_else : -> if_then_else (** [cmts_before_opt] return the comment before the given location with no breaks around it. *) +val needs_raw_cmts_after_kw : expression_desc -> bool +(** [needs_raw_cmts_after_kw desc] returns [true] when comments after the + keyword should be extracted without breaks (raw) to prevent oscillation + between "after keyword" and "before expression" placements. *) + +val raw_cmts_branch_pro : Conf.t -> Fmt.t -> Fmt.t +(** [raw_cmts_branch_pro c cmts] returns the branch_pro for raw comments + extracted after a keyword, using the correct indentation for the current + if-then-else mode. *) + val match_indent : ?default:int -> Conf.t -> parens:bool -> ctx:Ast.t -> int (** [match_indent c ~ctx ~default] returns the indentation used for the pattern-matching in context [ctx], depending on the `match-indent-nested` diff --git a/test/passing/refs.ahrefs/ite-compact.ml.err b/test/passing/refs.ahrefs/ite-compact.ml.err index eabdb2ceb5..c0f70ad2c7 100644 --- a/test/passing/refs.ahrefs/ite-compact.ml.err +++ b/test/passing/refs.ahrefs/ite-compact.ml.err @@ -1,3 +1,5 @@ Warning: ite-compact.ml:95 exceeds the margin Warning: ite-compact.ml:100 exceeds the margin Warning: ite-compact.ml:105 exceeds the margin +Warning: ite-compact.ml:210 exceeds the margin +Warning: ite-compact.ml:219 exceeds the margin diff --git a/test/passing/refs.ahrefs/ite-compact.ml.ref b/test/passing/refs.ahrefs/ite-compact.ml.ref index 1d6ab52118..62816583fb 100644 --- a/test/passing/refs.ahrefs/ite-compact.ml.ref +++ b/test/passing/refs.ahrefs/ite-compact.ml.ref @@ -201,3 +201,32 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f) + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.ahrefs/ite-compact_closing.ml.err b/test/passing/refs.ahrefs/ite-compact_closing.ml.err index e69de29bb2..a7feaef014 100644 --- a/test/passing/refs.ahrefs/ite-compact_closing.ml.err +++ b/test/passing/refs.ahrefs/ite-compact_closing.ml.err @@ -0,0 +1,2 @@ +Warning: ite-compact_closing.ml:229 exceeds the margin +Warning: ite-compact_closing.ml:238 exceeds the margin diff --git a/test/passing/refs.ahrefs/ite-compact_closing.ml.ref b/test/passing/refs.ahrefs/ite-compact_closing.ml.ref index 5ff4ee5375..5325ce7382 100644 --- a/test/passing/refs.ahrefs/ite-compact_closing.ml.ref +++ b/test/passing/refs.ahrefs/ite-compact_closing.ml.ref @@ -220,3 +220,33 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + ) + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.ahrefs/ite-fit_or_vertical.ml.err b/test/passing/refs.ahrefs/ite-fit_or_vertical.ml.err index 99497a0269..fc51770a03 100644 --- a/test/passing/refs.ahrefs/ite-fit_or_vertical.ml.err +++ b/test/passing/refs.ahrefs/ite-fit_or_vertical.ml.err @@ -1,3 +1,5 @@ Warning: ite-fit_or_vertical.ml:116 exceeds the margin Warning: ite-fit_or_vertical.ml:121 exceeds the margin Warning: ite-fit_or_vertical.ml:126 exceeds the margin +Warning: ite-fit_or_vertical.ml:247 exceeds the margin +Warning: ite-fit_or_vertical.ml:260 exceeds the margin diff --git a/test/passing/refs.ahrefs/ite-fit_or_vertical.ml.ref b/test/passing/refs.ahrefs/ite-fit_or_vertical.ml.ref index 4689df62e1..f6dbbe1bc9 100644 --- a/test/passing/refs.ahrefs/ite-fit_or_vertical.ml.ref +++ b/test/passing/refs.ahrefs/ite-fit_or_vertical.ml.ref @@ -238,3 +238,38 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if + a + then + b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *)( + match x with + | A -> f) + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.ahrefs/ite-fit_or_vertical_closing.ml.err b/test/passing/refs.ahrefs/ite-fit_or_vertical_closing.ml.err index e69de29bb2..5fedffb9e3 100644 --- a/test/passing/refs.ahrefs/ite-fit_or_vertical_closing.ml.err +++ b/test/passing/refs.ahrefs/ite-fit_or_vertical_closing.ml.err @@ -0,0 +1,2 @@ +Warning: ite-fit_or_vertical_closing.ml:257 exceeds the margin +Warning: ite-fit_or_vertical_closing.ml:270 exceeds the margin diff --git a/test/passing/refs.ahrefs/ite-fit_or_vertical_closing.ml.ref b/test/passing/refs.ahrefs/ite-fit_or_vertical_closing.ml.ref index 375f63ecb7..568bde8b61 100644 --- a/test/passing/refs.ahrefs/ite-fit_or_vertical_closing.ml.ref +++ b/test/passing/refs.ahrefs/ite-fit_or_vertical_closing.ml.ref @@ -248,3 +248,39 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if + a + then + b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *)( + match x with + | A -> f + ) + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.ahrefs/ite-fit_or_vertical_no_indicate.ml.err b/test/passing/refs.ahrefs/ite-fit_or_vertical_no_indicate.ml.err index 3fbf4ce7a7..9eff570afe 100644 --- a/test/passing/refs.ahrefs/ite-fit_or_vertical_no_indicate.ml.err +++ b/test/passing/refs.ahrefs/ite-fit_or_vertical_no_indicate.ml.err @@ -1,3 +1,5 @@ Warning: ite-fit_or_vertical_no_indicate.ml:116 exceeds the margin Warning: ite-fit_or_vertical_no_indicate.ml:121 exceeds the margin Warning: ite-fit_or_vertical_no_indicate.ml:126 exceeds the margin +Warning: ite-fit_or_vertical_no_indicate.ml:247 exceeds the margin +Warning: ite-fit_or_vertical_no_indicate.ml:260 exceeds the margin diff --git a/test/passing/refs.ahrefs/ite-fit_or_vertical_no_indicate.ml.ref b/test/passing/refs.ahrefs/ite-fit_or_vertical_no_indicate.ml.ref index 4689df62e1..f6dbbe1bc9 100644 --- a/test/passing/refs.ahrefs/ite-fit_or_vertical_no_indicate.ml.ref +++ b/test/passing/refs.ahrefs/ite-fit_or_vertical_no_indicate.ml.ref @@ -238,3 +238,38 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if + a + then + b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *)( + match x with + | A -> f) + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.ahrefs/ite-kr.ml.err b/test/passing/refs.ahrefs/ite-kr.ml.err index e69de29bb2..e629f10e04 100644 --- a/test/passing/refs.ahrefs/ite-kr.ml.err +++ b/test/passing/refs.ahrefs/ite-kr.ml.err @@ -0,0 +1,2 @@ +Warning: ite-kr.ml:286 exceeds the margin +Warning: ite-kr.ml:296 exceeds the margin diff --git a/test/passing/refs.ahrefs/ite-kr.ml.ref b/test/passing/refs.ahrefs/ite-kr.ml.ref index 6855390802..40be4b4384 100644 --- a/test/passing/refs.ahrefs/ite-kr.ml.ref +++ b/test/passing/refs.ahrefs/ite-kr.ml.ref @@ -277,3 +277,36 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + ) + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.ahrefs/ite-kr_closing.ml.err b/test/passing/refs.ahrefs/ite-kr_closing.ml.err index e69de29bb2..6c9cdc7a83 100644 --- a/test/passing/refs.ahrefs/ite-kr_closing.ml.err +++ b/test/passing/refs.ahrefs/ite-kr_closing.ml.err @@ -0,0 +1,2 @@ +Warning: ite-kr_closing.ml:293 exceeds the margin +Warning: ite-kr_closing.ml:303 exceeds the margin diff --git a/test/passing/refs.ahrefs/ite-kr_closing.ml.ref b/test/passing/refs.ahrefs/ite-kr_closing.ml.ref index a85ad80835..fdf791c892 100644 --- a/test/passing/refs.ahrefs/ite-kr_closing.ml.ref +++ b/test/passing/refs.ahrefs/ite-kr_closing.ml.ref @@ -284,3 +284,36 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + ) + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.ahrefs/ite-kw_first.ml.err b/test/passing/refs.ahrefs/ite-kw_first.ml.err index b7a7965b28..8db834286e 100644 --- a/test/passing/refs.ahrefs/ite-kw_first.ml.err +++ b/test/passing/refs.ahrefs/ite-kw_first.ml.err @@ -1,3 +1,5 @@ Warning: ite-kw_first.ml:110 exceeds the margin Warning: ite-kw_first.ml:116 exceeds the margin Warning: ite-kw_first.ml:121 exceeds the margin +Warning: ite-kw_first.ml:242 exceeds the margin +Warning: ite-kw_first.ml:252 exceeds the margin diff --git a/test/passing/refs.ahrefs/ite-kw_first.ml.ref b/test/passing/refs.ahrefs/ite-kw_first.ml.ref index 2bc4b9ddca..0dd5acf1bc 100644 --- a/test/passing/refs.ahrefs/ite-kw_first.ml.ref +++ b/test/passing/refs.ahrefs/ite-kw_first.ml.ref @@ -232,3 +232,36 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf + then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a + then b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f) + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa + then + if bbbbb + then + (* in this case, b <- s *) + if abs_float fa < abs_float fs + then iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.ahrefs/ite-kw_first_closing.ml.err b/test/passing/refs.ahrefs/ite-kw_first_closing.ml.err index e69de29bb2..cded66bdf6 100644 --- a/test/passing/refs.ahrefs/ite-kw_first_closing.ml.err +++ b/test/passing/refs.ahrefs/ite-kw_first_closing.ml.err @@ -0,0 +1,2 @@ +Warning: ite-kw_first_closing.ml:261 exceeds the margin +Warning: ite-kw_first_closing.ml:271 exceeds the margin diff --git a/test/passing/refs.ahrefs/ite-kw_first_closing.ml.ref b/test/passing/refs.ahrefs/ite-kw_first_closing.ml.ref index b2f0bae1e5..e0b9284f1d 100644 --- a/test/passing/refs.ahrefs/ite-kw_first_closing.ml.ref +++ b/test/passing/refs.ahrefs/ite-kw_first_closing.ml.ref @@ -251,3 +251,37 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf + then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a + then b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + ) + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa + then + if bbbbb + then + (* in this case, b <- s *) + if abs_float fa < abs_float fs + then iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.ahrefs/ite-kw_first_no_indicate.ml.err b/test/passing/refs.ahrefs/ite-kw_first_no_indicate.ml.err index f2ca3caec5..bc36f4b3f0 100644 --- a/test/passing/refs.ahrefs/ite-kw_first_no_indicate.ml.err +++ b/test/passing/refs.ahrefs/ite-kw_first_no_indicate.ml.err @@ -1,3 +1,5 @@ Warning: ite-kw_first_no_indicate.ml:110 exceeds the margin Warning: ite-kw_first_no_indicate.ml:116 exceeds the margin Warning: ite-kw_first_no_indicate.ml:121 exceeds the margin +Warning: ite-kw_first_no_indicate.ml:242 exceeds the margin +Warning: ite-kw_first_no_indicate.ml:252 exceeds the margin diff --git a/test/passing/refs.ahrefs/ite-kw_first_no_indicate.ml.ref b/test/passing/refs.ahrefs/ite-kw_first_no_indicate.ml.ref index 2bc4b9ddca..0dd5acf1bc 100644 --- a/test/passing/refs.ahrefs/ite-kw_first_no_indicate.ml.ref +++ b/test/passing/refs.ahrefs/ite-kw_first_no_indicate.ml.ref @@ -232,3 +232,36 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf + then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a + then b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f) + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa + then + if bbbbb + then + (* in this case, b <- s *) + if abs_float fa < abs_float fs + then iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.ahrefs/ite-no_indicate.ml.err b/test/passing/refs.ahrefs/ite-no_indicate.ml.err index eacaa90390..818346ef1e 100644 --- a/test/passing/refs.ahrefs/ite-no_indicate.ml.err +++ b/test/passing/refs.ahrefs/ite-no_indicate.ml.err @@ -1,3 +1,5 @@ Warning: ite-no_indicate.ml:95 exceeds the margin Warning: ite-no_indicate.ml:100 exceeds the margin Warning: ite-no_indicate.ml:105 exceeds the margin +Warning: ite-no_indicate.ml:210 exceeds the margin +Warning: ite-no_indicate.ml:219 exceeds the margin diff --git a/test/passing/refs.ahrefs/ite-no_indicate.ml.ref b/test/passing/refs.ahrefs/ite-no_indicate.ml.ref index 1d6ab52118..62816583fb 100644 --- a/test/passing/refs.ahrefs/ite-no_indicate.ml.ref +++ b/test/passing/refs.ahrefs/ite-no_indicate.ml.ref @@ -201,3 +201,32 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f) + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.ahrefs/ite-vertical.ml.err b/test/passing/refs.ahrefs/ite-vertical.ml.err index 78b448a6a4..b2aa89ed3a 100644 --- a/test/passing/refs.ahrefs/ite-vertical.ml.err +++ b/test/passing/refs.ahrefs/ite-vertical.ml.err @@ -1,3 +1,5 @@ Warning: ite-vertical.ml:131 exceeds the margin Warning: ite-vertical.ml:136 exceeds the margin Warning: ite-vertical.ml:141 exceeds the margin +Warning: ite-vertical.ml:284 exceeds the margin +Warning: ite-vertical.ml:297 exceeds the margin diff --git a/test/passing/refs.ahrefs/ite-vertical.ml.ref b/test/passing/refs.ahrefs/ite-vertical.ml.ref index 231b1748f2..6d41adb8e8 100644 --- a/test/passing/refs.ahrefs/ite-vertical.ml.ref +++ b/test/passing/refs.ahrefs/ite-vertical.ml.ref @@ -275,3 +275,38 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if + a + then + b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f) + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.ahrefs/ite.ml.err b/test/passing/refs.ahrefs/ite.ml.err index 15a41f8299..1ea8e951e5 100644 --- a/test/passing/refs.ahrefs/ite.ml.err +++ b/test/passing/refs.ahrefs/ite.ml.err @@ -1,3 +1,5 @@ Warning: ite.ml:95 exceeds the margin Warning: ite.ml:100 exceeds the margin Warning: ite.ml:105 exceeds the margin +Warning: ite.ml:210 exceeds the margin +Warning: ite.ml:219 exceeds the margin diff --git a/test/passing/refs.ahrefs/ite.ml.ref b/test/passing/refs.ahrefs/ite.ml.ref index 1d6ab52118..62816583fb 100644 --- a/test/passing/refs.ahrefs/ite.ml.ref +++ b/test/passing/refs.ahrefs/ite.ml.ref @@ -201,3 +201,32 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f) + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.default/ite-compact.ml.err b/test/passing/refs.default/ite-compact.ml.err index 98c1f5fdf5..8f6b0dea72 100644 --- a/test/passing/refs.default/ite-compact.ml.err +++ b/test/passing/refs.default/ite-compact.ml.err @@ -1,3 +1,5 @@ Warning: ite-compact.ml:94 exceeds the margin Warning: ite-compact.ml:99 exceeds the margin Warning: ite-compact.ml:104 exceeds the margin +Warning: ite-compact.ml:204 exceeds the margin +Warning: ite-compact.ml:213 exceeds the margin diff --git a/test/passing/refs.default/ite-compact.ml.ref b/test/passing/refs.default/ite-compact.ml.ref index 388a6d195f..3672c44671 100644 --- a/test/passing/refs.default/ite-compact.ml.ref +++ b/test/passing/refs.default/ite-compact.ml.ref @@ -195,3 +195,31 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.default/ite-compact_closing.ml.err b/test/passing/refs.default/ite-compact_closing.ml.err index e69de29bb2..8797c86ff1 100644 --- a/test/passing/refs.default/ite-compact_closing.ml.err +++ b/test/passing/refs.default/ite-compact_closing.ml.err @@ -0,0 +1,2 @@ +Warning: ite-compact_closing.ml:219 exceeds the margin +Warning: ite-compact_closing.ml:228 exceeds the margin diff --git a/test/passing/refs.default/ite-compact_closing.ml.ref b/test/passing/refs.default/ite-compact_closing.ml.ref index b0b0c4e0a8..8fc1245502 100644 --- a/test/passing/refs.default/ite-compact_closing.ml.ref +++ b/test/passing/refs.default/ite-compact_closing.ml.ref @@ -210,3 +210,31 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.default/ite-fit_or_vertical.ml.err b/test/passing/refs.default/ite-fit_or_vertical.ml.err index 3e7a9278f6..19b7a99c10 100644 --- a/test/passing/refs.default/ite-fit_or_vertical.ml.err +++ b/test/passing/refs.default/ite-fit_or_vertical.ml.err @@ -1,3 +1,5 @@ Warning: ite-fit_or_vertical.ml:115 exceeds the margin Warning: ite-fit_or_vertical.ml:120 exceeds the margin Warning: ite-fit_or_vertical.ml:125 exceeds the margin +Warning: ite-fit_or_vertical.ml:247 exceeds the margin +Warning: ite-fit_or_vertical.ml:260 exceeds the margin diff --git a/test/passing/refs.default/ite-fit_or_vertical.ml.ref b/test/passing/refs.default/ite-fit_or_vertical.ml.ref index b081309e03..4214040eeb 100644 --- a/test/passing/refs.default/ite-fit_or_vertical.ml.ref +++ b/test/passing/refs.default/ite-fit_or_vertical.ml.ref @@ -238,3 +238,38 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if + a + then + b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.default/ite-fit_or_vertical_closing.ml.err b/test/passing/refs.default/ite-fit_or_vertical_closing.ml.err index e69de29bb2..126313710f 100644 --- a/test/passing/refs.default/ite-fit_or_vertical_closing.ml.err +++ b/test/passing/refs.default/ite-fit_or_vertical_closing.ml.err @@ -0,0 +1,2 @@ +Warning: ite-fit_or_vertical_closing.ml:256 exceeds the margin +Warning: ite-fit_or_vertical_closing.ml:269 exceeds the margin diff --git a/test/passing/refs.default/ite-fit_or_vertical_closing.ml.ref b/test/passing/refs.default/ite-fit_or_vertical_closing.ml.ref index 7df4f5afaa..64810afbfe 100644 --- a/test/passing/refs.default/ite-fit_or_vertical_closing.ml.ref +++ b/test/passing/refs.default/ite-fit_or_vertical_closing.ml.ref @@ -247,3 +247,38 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if + a + then + b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.default/ite-fit_or_vertical_no_indicate.ml.err b/test/passing/refs.default/ite-fit_or_vertical_no_indicate.ml.err index d5be88bb2e..bef0700a1d 100644 --- a/test/passing/refs.default/ite-fit_or_vertical_no_indicate.ml.err +++ b/test/passing/refs.default/ite-fit_or_vertical_no_indicate.ml.err @@ -1,3 +1,5 @@ Warning: ite-fit_or_vertical_no_indicate.ml:115 exceeds the margin Warning: ite-fit_or_vertical_no_indicate.ml:120 exceeds the margin Warning: ite-fit_or_vertical_no_indicate.ml:125 exceeds the margin +Warning: ite-fit_or_vertical_no_indicate.ml:247 exceeds the margin +Warning: ite-fit_or_vertical_no_indicate.ml:260 exceeds the margin diff --git a/test/passing/refs.default/ite-fit_or_vertical_no_indicate.ml.ref b/test/passing/refs.default/ite-fit_or_vertical_no_indicate.ml.ref index b081309e03..4214040eeb 100644 --- a/test/passing/refs.default/ite-fit_or_vertical_no_indicate.ml.ref +++ b/test/passing/refs.default/ite-fit_or_vertical_no_indicate.ml.ref @@ -238,3 +238,38 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if + a + then + b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.default/ite-kr.ml.err b/test/passing/refs.default/ite-kr.ml.err index e69de29bb2..64cbf368c6 100644 --- a/test/passing/refs.default/ite-kr.ml.err +++ b/test/passing/refs.default/ite-kr.ml.err @@ -0,0 +1,2 @@ +Warning: ite-kr.ml:283 exceeds the margin +Warning: ite-kr.ml:293 exceeds the margin diff --git a/test/passing/refs.default/ite-kr.ml.ref b/test/passing/refs.default/ite-kr.ml.ref index 544491faa7..0773c03e16 100644 --- a/test/passing/refs.default/ite-kr.ml.ref +++ b/test/passing/refs.default/ite-kr.ml.ref @@ -274,3 +274,35 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.default/ite-kr_closing.ml.err b/test/passing/refs.default/ite-kr_closing.ml.err index e69de29bb2..b5b63b74ff 100644 --- a/test/passing/refs.default/ite-kr_closing.ml.err +++ b/test/passing/refs.default/ite-kr_closing.ml.err @@ -0,0 +1,2 @@ +Warning: ite-kr_closing.ml:290 exceeds the margin +Warning: ite-kr_closing.ml:300 exceeds the margin diff --git a/test/passing/refs.default/ite-kr_closing.ml.ref b/test/passing/refs.default/ite-kr_closing.ml.ref index 185c07d8af..d16ca01a77 100644 --- a/test/passing/refs.default/ite-kr_closing.ml.ref +++ b/test/passing/refs.default/ite-kr_closing.ml.ref @@ -281,3 +281,35 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.default/ite-kw_first.ml.err b/test/passing/refs.default/ite-kw_first.ml.err index 4581a47a8a..c3521caee9 100644 --- a/test/passing/refs.default/ite-kw_first.ml.err +++ b/test/passing/refs.default/ite-kw_first.ml.err @@ -1,3 +1,5 @@ Warning: ite-kw_first.ml:109 exceeds the margin Warning: ite-kw_first.ml:115 exceeds the margin Warning: ite-kw_first.ml:120 exceeds the margin +Warning: ite-kw_first.ml:236 exceeds the margin +Warning: ite-kw_first.ml:246 exceeds the margin diff --git a/test/passing/refs.default/ite-kw_first.ml.ref b/test/passing/refs.default/ite-kw_first.ml.ref index fbba1e9a14..a0941721b7 100644 --- a/test/passing/refs.default/ite-kw_first.ml.ref +++ b/test/passing/refs.default/ite-kw_first.ml.ref @@ -226,3 +226,36 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf + then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a + then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa + then + if bbbbb + then + (* in this case, b <- s *) + if abs_float fa < abs_float fs + then iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.default/ite-kw_first_closing.ml.err b/test/passing/refs.default/ite-kw_first_closing.ml.err index e69de29bb2..8d1eb35530 100644 --- a/test/passing/refs.default/ite-kw_first_closing.ml.err +++ b/test/passing/refs.default/ite-kw_first_closing.ml.err @@ -0,0 +1,2 @@ +Warning: ite-kw_first_closing.ml:251 exceeds the margin +Warning: ite-kw_first_closing.ml:261 exceeds the margin diff --git a/test/passing/refs.default/ite-kw_first_closing.ml.ref b/test/passing/refs.default/ite-kw_first_closing.ml.ref index 98cd1fa74b..546b602f91 100644 --- a/test/passing/refs.default/ite-kw_first_closing.ml.ref +++ b/test/passing/refs.default/ite-kw_first_closing.ml.ref @@ -241,3 +241,36 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf + then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a + then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa + then + if bbbbb + then + (* in this case, b <- s *) + if abs_float fa < abs_float fs + then iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.default/ite-kw_first_no_indicate.ml.err b/test/passing/refs.default/ite-kw_first_no_indicate.ml.err index 62411d1164..fffd7e1117 100644 --- a/test/passing/refs.default/ite-kw_first_no_indicate.ml.err +++ b/test/passing/refs.default/ite-kw_first_no_indicate.ml.err @@ -1,3 +1,5 @@ Warning: ite-kw_first_no_indicate.ml:109 exceeds the margin Warning: ite-kw_first_no_indicate.ml:115 exceeds the margin Warning: ite-kw_first_no_indicate.ml:120 exceeds the margin +Warning: ite-kw_first_no_indicate.ml:236 exceeds the margin +Warning: ite-kw_first_no_indicate.ml:246 exceeds the margin diff --git a/test/passing/refs.default/ite-kw_first_no_indicate.ml.ref b/test/passing/refs.default/ite-kw_first_no_indicate.ml.ref index fbba1e9a14..a0941721b7 100644 --- a/test/passing/refs.default/ite-kw_first_no_indicate.ml.ref +++ b/test/passing/refs.default/ite-kw_first_no_indicate.ml.ref @@ -226,3 +226,36 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf + then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a + then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa + then + if bbbbb + then + (* in this case, b <- s *) + if abs_float fa < abs_float fs + then iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.default/ite-no_indicate.ml.err b/test/passing/refs.default/ite-no_indicate.ml.err index 4f2be9a3f0..3ff08667d3 100644 --- a/test/passing/refs.default/ite-no_indicate.ml.err +++ b/test/passing/refs.default/ite-no_indicate.ml.err @@ -1,3 +1,5 @@ Warning: ite-no_indicate.ml:94 exceeds the margin Warning: ite-no_indicate.ml:99 exceeds the margin Warning: ite-no_indicate.ml:104 exceeds the margin +Warning: ite-no_indicate.ml:204 exceeds the margin +Warning: ite-no_indicate.ml:213 exceeds the margin diff --git a/test/passing/refs.default/ite-no_indicate.ml.ref b/test/passing/refs.default/ite-no_indicate.ml.ref index 388a6d195f..3672c44671 100644 --- a/test/passing/refs.default/ite-no_indicate.ml.ref +++ b/test/passing/refs.default/ite-no_indicate.ml.ref @@ -195,3 +195,31 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.default/ite-vertical.ml.err b/test/passing/refs.default/ite-vertical.ml.err index 78b448a6a4..3a6f50f9a7 100644 --- a/test/passing/refs.default/ite-vertical.ml.err +++ b/test/passing/refs.default/ite-vertical.ml.err @@ -1,3 +1,5 @@ Warning: ite-vertical.ml:131 exceeds the margin Warning: ite-vertical.ml:136 exceeds the margin Warning: ite-vertical.ml:141 exceeds the margin +Warning: ite-vertical.ml:286 exceeds the margin +Warning: ite-vertical.ml:299 exceeds the margin diff --git a/test/passing/refs.default/ite-vertical.ml.ref b/test/passing/refs.default/ite-vertical.ml.ref index 2f93d4b4e9..04eb6fbb61 100644 --- a/test/passing/refs.default/ite-vertical.ml.ref +++ b/test/passing/refs.default/ite-vertical.ml.ref @@ -277,3 +277,38 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if + a + then + b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.default/ite.ml.err b/test/passing/refs.default/ite.ml.err index 40ba7d9c17..93bdb1d0e9 100644 --- a/test/passing/refs.default/ite.ml.err +++ b/test/passing/refs.default/ite.ml.err @@ -1,3 +1,5 @@ Warning: ite.ml:94 exceeds the margin Warning: ite.ml:99 exceeds the margin Warning: ite.ml:104 exceeds the margin +Warning: ite.ml:204 exceeds the margin +Warning: ite.ml:213 exceeds the margin diff --git a/test/passing/refs.default/ite.ml.ref b/test/passing/refs.default/ite.ml.ref index 388a6d195f..3672c44671 100644 --- a/test/passing/refs.default/ite.ml.ref +++ b/test/passing/refs.default/ite.ml.ref @@ -195,3 +195,31 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.janestreet/ite-compact.ml.ref b/test/passing/refs.janestreet/ite-compact.ml.ref index 00417e294c..02d22ac756 100644 --- a/test/passing/refs.janestreet/ite-compact.ml.ref +++ b/test/passing/refs.janestreet/ite-compact.ml.ref @@ -204,3 +204,34 @@ let test = 1 else 2 ;; + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + if a then b +;; + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f) +;; + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g +;; diff --git a/test/passing/refs.janestreet/ite-compact_closing.ml.ref b/test/passing/refs.janestreet/ite-compact_closing.ml.ref index f912432e3b..e98406e08f 100644 --- a/test/passing/refs.janestreet/ite-compact_closing.ml.ref +++ b/test/passing/refs.janestreet/ite-compact_closing.ml.ref @@ -218,3 +218,35 @@ let test = 1 else 2 ;; + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + if a then b +;; + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + ) +;; + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g +;; diff --git a/test/passing/refs.janestreet/ite-fit_or_vertical.ml.ref b/test/passing/refs.janestreet/ite-fit_or_vertical.ml.ref index b43821df3d..35c0fdedf6 100644 --- a/test/passing/refs.janestreet/ite-fit_or_vertical.ml.ref +++ b/test/passing/refs.janestreet/ite-fit_or_vertical.ml.ref @@ -254,3 +254,37 @@ let test = else 2 ;; + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + if a then b +;; + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *)( + match x with + | A -> f) +;; + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g +;; diff --git a/test/passing/refs.janestreet/ite-fit_or_vertical_closing.ml.ref b/test/passing/refs.janestreet/ite-fit_or_vertical_closing.ml.ref index 0643a58e39..97b3d2aca5 100644 --- a/test/passing/refs.janestreet/ite-fit_or_vertical_closing.ml.ref +++ b/test/passing/refs.janestreet/ite-fit_or_vertical_closing.ml.ref @@ -265,3 +265,38 @@ let test = else 2 ;; + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + if a then b +;; + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *)( + match x with + | A -> f + ) +;; + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g +;; diff --git a/test/passing/refs.janestreet/ite-fit_or_vertical_no_indicate.ml.ref b/test/passing/refs.janestreet/ite-fit_or_vertical_no_indicate.ml.ref index b43821df3d..35c0fdedf6 100644 --- a/test/passing/refs.janestreet/ite-fit_or_vertical_no_indicate.ml.ref +++ b/test/passing/refs.janestreet/ite-fit_or_vertical_no_indicate.ml.ref @@ -254,3 +254,37 @@ let test = else 2 ;; + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + if a then b +;; + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *)( + match x with + | A -> f) +;; + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g +;; diff --git a/test/passing/refs.janestreet/ite-kr.ml.ref b/test/passing/refs.janestreet/ite-kr.ml.ref index 01a753c050..20a2ed5f27 100644 --- a/test/passing/refs.janestreet/ite-kr.ml.ref +++ b/test/passing/refs.janestreet/ite-kr.ml.ref @@ -301,3 +301,38 @@ let test = else 2 ;; + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + if a then b +;; + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + ) +;; + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g +;; diff --git a/test/passing/refs.janestreet/ite-kr_closing.ml.ref b/test/passing/refs.janestreet/ite-kr_closing.ml.ref index 84a9ba27ce..0bcf83e649 100644 --- a/test/passing/refs.janestreet/ite-kr_closing.ml.ref +++ b/test/passing/refs.janestreet/ite-kr_closing.ml.ref @@ -308,3 +308,38 @@ let test = else 2 ;; + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + if a then b +;; + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + ) +;; + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g +;; diff --git a/test/passing/refs.janestreet/ite-kw_first.ml.ref b/test/passing/refs.janestreet/ite-kw_first.ml.ref index 95f725561a..2b16944d25 100644 --- a/test/passing/refs.janestreet/ite-kw_first.ml.ref +++ b/test/passing/refs.janestreet/ite-kw_first.ml.ref @@ -234,3 +234,38 @@ let test = 1 else 2 ;; + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf + then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + if a then b +;; + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a + then b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f) +;; + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa + then + if bbbbb + then + (* in this case, b <- s *) + if abs_float fa < abs_float fs + then iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g +;; diff --git a/test/passing/refs.janestreet/ite-kw_first_closing.ml.ref b/test/passing/refs.janestreet/ite-kw_first_closing.ml.ref index 45e5d21b96..3111239793 100644 --- a/test/passing/refs.janestreet/ite-kw_first_closing.ml.ref +++ b/test/passing/refs.janestreet/ite-kw_first_closing.ml.ref @@ -248,3 +248,39 @@ let test = 1 else 2 ;; + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf + then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + if a then b +;; + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a + then b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + ) +;; + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa + then + if bbbbb + then + (* in this case, b <- s *) + if abs_float fa < abs_float fs + then iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g +;; diff --git a/test/passing/refs.janestreet/ite-kw_first_no_indicate.ml.ref b/test/passing/refs.janestreet/ite-kw_first_no_indicate.ml.ref index 95f725561a..2b16944d25 100644 --- a/test/passing/refs.janestreet/ite-kw_first_no_indicate.ml.ref +++ b/test/passing/refs.janestreet/ite-kw_first_no_indicate.ml.ref @@ -234,3 +234,38 @@ let test = 1 else 2 ;; + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf + then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + if a then b +;; + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a + then b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f) +;; + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa + then + if bbbbb + then + (* in this case, b <- s *) + if abs_float fa < abs_float fs + then iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g +;; diff --git a/test/passing/refs.janestreet/ite-no_indicate.ml.ref b/test/passing/refs.janestreet/ite-no_indicate.ml.ref index 00417e294c..02d22ac756 100644 --- a/test/passing/refs.janestreet/ite-no_indicate.ml.ref +++ b/test/passing/refs.janestreet/ite-no_indicate.ml.ref @@ -204,3 +204,34 @@ let test = 1 else 2 ;; + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + if a then b +;; + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f) +;; + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g +;; diff --git a/test/passing/refs.janestreet/ite-vertical.ml.ref b/test/passing/refs.janestreet/ite-vertical.ml.ref index 5d81ed9727..d99e8aad56 100644 --- a/test/passing/refs.janestreet/ite-vertical.ml.ref +++ b/test/passing/refs.janestreet/ite-vertical.ml.ref @@ -298,3 +298,38 @@ let test = else 2 ;; + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + if a then + b +;; + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f) +;; + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g +;; diff --git a/test/passing/refs.janestreet/ite.ml.ref b/test/passing/refs.janestreet/ite.ml.ref index 00417e294c..02d22ac756 100644 --- a/test/passing/refs.janestreet/ite.ml.ref +++ b/test/passing/refs.janestreet/ite.ml.ref @@ -204,3 +204,34 @@ let test = 1 else 2 ;; + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + if a then b +;; + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else ( + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f) +;; + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g +;; diff --git a/test/passing/refs.ocamlformat/ite-compact.ml.err b/test/passing/refs.ocamlformat/ite-compact.ml.err index e69de29bb2..dc50397179 100644 --- a/test/passing/refs.ocamlformat/ite-compact.ml.err +++ b/test/passing/refs.ocamlformat/ite-compact.ml.err @@ -0,0 +1,2 @@ +Warning: ite-compact.ml:203 exceeds the margin +Warning: ite-compact.ml:212 exceeds the margin diff --git a/test/passing/refs.ocamlformat/ite-compact.ml.ref b/test/passing/refs.ocamlformat/ite-compact.ml.ref index a91002de0b..4860d9f001 100644 --- a/test/passing/refs.ocamlformat/ite-compact.ml.ref +++ b/test/passing/refs.ocamlformat/ite-compact.ml.ref @@ -194,3 +194,31 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.ocamlformat/ite-compact_closing.ml.err b/test/passing/refs.ocamlformat/ite-compact_closing.ml.err index e69de29bb2..cd613b42f7 100644 --- a/test/passing/refs.ocamlformat/ite-compact_closing.ml.err +++ b/test/passing/refs.ocamlformat/ite-compact_closing.ml.err @@ -0,0 +1,2 @@ +Warning: ite-compact_closing.ml:213 exceeds the margin +Warning: ite-compact_closing.ml:222 exceeds the margin diff --git a/test/passing/refs.ocamlformat/ite-compact_closing.ml.ref b/test/passing/refs.ocamlformat/ite-compact_closing.ml.ref index ba252c671a..d7fb7bea79 100644 --- a/test/passing/refs.ocamlformat/ite-compact_closing.ml.ref +++ b/test/passing/refs.ocamlformat/ite-compact_closing.ml.ref @@ -204,3 +204,31 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.ocamlformat/ite-fit_or_vertical.ml.err b/test/passing/refs.ocamlformat/ite-fit_or_vertical.ml.err index e69de29bb2..35c4dd8d0a 100644 --- a/test/passing/refs.ocamlformat/ite-fit_or_vertical.ml.err +++ b/test/passing/refs.ocamlformat/ite-fit_or_vertical.ml.err @@ -0,0 +1,2 @@ +Warning: ite-fit_or_vertical.ml:250 exceeds the margin +Warning: ite-fit_or_vertical.ml:263 exceeds the margin diff --git a/test/passing/refs.ocamlformat/ite-fit_or_vertical.ml.ref b/test/passing/refs.ocamlformat/ite-fit_or_vertical.ml.ref index fea1f83a6a..dba064e102 100644 --- a/test/passing/refs.ocamlformat/ite-fit_or_vertical.ml.ref +++ b/test/passing/refs.ocamlformat/ite-fit_or_vertical.ml.ref @@ -241,3 +241,39 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if + a + then + b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> + f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.ocamlformat/ite-fit_or_vertical_closing.ml.err b/test/passing/refs.ocamlformat/ite-fit_or_vertical_closing.ml.err index e69de29bb2..23c64dbaf7 100644 --- a/test/passing/refs.ocamlformat/ite-fit_or_vertical_closing.ml.err +++ b/test/passing/refs.ocamlformat/ite-fit_or_vertical_closing.ml.err @@ -0,0 +1,2 @@ +Warning: ite-fit_or_vertical_closing.ml:255 exceeds the margin +Warning: ite-fit_or_vertical_closing.ml:268 exceeds the margin diff --git a/test/passing/refs.ocamlformat/ite-fit_or_vertical_closing.ml.ref b/test/passing/refs.ocamlformat/ite-fit_or_vertical_closing.ml.ref index ad0e75c24f..fda9f31bfd 100644 --- a/test/passing/refs.ocamlformat/ite-fit_or_vertical_closing.ml.ref +++ b/test/passing/refs.ocamlformat/ite-fit_or_vertical_closing.ml.ref @@ -246,3 +246,39 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if + a + then + b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> + f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.ocamlformat/ite-fit_or_vertical_no_indicate.ml.err b/test/passing/refs.ocamlformat/ite-fit_or_vertical_no_indicate.ml.err index 68b7f4e485..0ef658ec2b 100644 --- a/test/passing/refs.ocamlformat/ite-fit_or_vertical_no_indicate.ml.err +++ b/test/passing/refs.ocamlformat/ite-fit_or_vertical_no_indicate.ml.err @@ -1,3 +1,5 @@ Warning: ite-fit_or_vertical_no_indicate.ml:110 exceeds the margin Warning: ite-fit_or_vertical_no_indicate.ml:115 exceeds the margin Warning: ite-fit_or_vertical_no_indicate.ml:120 exceeds the margin +Warning: ite-fit_or_vertical_no_indicate.ml:247 exceeds the margin +Warning: ite-fit_or_vertical_no_indicate.ml:260 exceeds the margin diff --git a/test/passing/refs.ocamlformat/ite-fit_or_vertical_no_indicate.ml.ref b/test/passing/refs.ocamlformat/ite-fit_or_vertical_no_indicate.ml.ref index 21927aea92..5faeb08f42 100644 --- a/test/passing/refs.ocamlformat/ite-fit_or_vertical_no_indicate.ml.ref +++ b/test/passing/refs.ocamlformat/ite-fit_or_vertical_no_indicate.ml.ref @@ -238,3 +238,39 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if + a + then + b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> + f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.ocamlformat/ite-kr.ml.err b/test/passing/refs.ocamlformat/ite-kr.ml.err index e69de29bb2..0cbaa87224 100644 --- a/test/passing/refs.ocamlformat/ite-kr.ml.err +++ b/test/passing/refs.ocamlformat/ite-kr.ml.err @@ -0,0 +1,2 @@ +Warning: ite-kr.ml:284 exceeds the margin +Warning: ite-kr.ml:294 exceeds the margin diff --git a/test/passing/refs.ocamlformat/ite-kr.ml.ref b/test/passing/refs.ocamlformat/ite-kr.ml.ref index d72c9d9420..7a8ac0e004 100644 --- a/test/passing/refs.ocamlformat/ite-kr.ml.ref +++ b/test/passing/refs.ocamlformat/ite-kr.ml.ref @@ -275,3 +275,36 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> + f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.ocamlformat/ite-kr_closing.ml.err b/test/passing/refs.ocamlformat/ite-kr_closing.ml.err index e69de29bb2..a361ca020e 100644 --- a/test/passing/refs.ocamlformat/ite-kr_closing.ml.err +++ b/test/passing/refs.ocamlformat/ite-kr_closing.ml.err @@ -0,0 +1,2 @@ +Warning: ite-kr_closing.ml:288 exceeds the margin +Warning: ite-kr_closing.ml:298 exceeds the margin diff --git a/test/passing/refs.ocamlformat/ite-kr_closing.ml.ref b/test/passing/refs.ocamlformat/ite-kr_closing.ml.ref index bd3990874a..ca04feee60 100644 --- a/test/passing/refs.ocamlformat/ite-kr_closing.ml.ref +++ b/test/passing/refs.ocamlformat/ite-kr_closing.ml.ref @@ -279,3 +279,36 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> + f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.ocamlformat/ite-kw_first.ml.err b/test/passing/refs.ocamlformat/ite-kw_first.ml.err index e69de29bb2..bc1fa626c3 100644 --- a/test/passing/refs.ocamlformat/ite-kw_first.ml.err +++ b/test/passing/refs.ocamlformat/ite-kw_first.ml.err @@ -0,0 +1,2 @@ +Warning: ite-kw_first.ml:234 exceeds the margin +Warning: ite-kw_first.ml:244 exceeds the margin diff --git a/test/passing/refs.ocamlformat/ite-kw_first.ml.ref b/test/passing/refs.ocamlformat/ite-kw_first.ml.ref index 7481c0a4ce..df8130036d 100644 --- a/test/passing/refs.ocamlformat/ite-kw_first.ml.ref +++ b/test/passing/refs.ocamlformat/ite-kw_first.ml.ref @@ -224,3 +224,37 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf + then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a + then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> + f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa + then + if bbbbb + then + (* in this case, b <- s *) + if abs_float fa < abs_float fs + then iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.ocamlformat/ite-kw_first_closing.ml.err b/test/passing/refs.ocamlformat/ite-kw_first_closing.ml.err index e69de29bb2..9a104847cb 100644 --- a/test/passing/refs.ocamlformat/ite-kw_first_closing.ml.err +++ b/test/passing/refs.ocamlformat/ite-kw_first_closing.ml.err @@ -0,0 +1,2 @@ +Warning: ite-kw_first_closing.ml:244 exceeds the margin +Warning: ite-kw_first_closing.ml:254 exceeds the margin diff --git a/test/passing/refs.ocamlformat/ite-kw_first_closing.ml.ref b/test/passing/refs.ocamlformat/ite-kw_first_closing.ml.ref index 48796d00a7..b10567c2e3 100644 --- a/test/passing/refs.ocamlformat/ite-kw_first_closing.ml.ref +++ b/test/passing/refs.ocamlformat/ite-kw_first_closing.ml.ref @@ -234,3 +234,37 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf + then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a + then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> + f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa + then + if bbbbb + then + (* in this case, b <- s *) + if abs_float fa < abs_float fs + then iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.ocamlformat/ite-kw_first_no_indicate.ml.err b/test/passing/refs.ocamlformat/ite-kw_first_no_indicate.ml.err index e320f2fabf..2a0b106815 100644 --- a/test/passing/refs.ocamlformat/ite-kw_first_no_indicate.ml.err +++ b/test/passing/refs.ocamlformat/ite-kw_first_no_indicate.ml.err @@ -1,3 +1,5 @@ Warning: ite-kw_first_no_indicate.ml:103 exceeds the margin Warning: ite-kw_first_no_indicate.ml:109 exceeds the margin Warning: ite-kw_first_no_indicate.ml:114 exceeds the margin +Warning: ite-kw_first_no_indicate.ml:231 exceeds the margin +Warning: ite-kw_first_no_indicate.ml:241 exceeds the margin diff --git a/test/passing/refs.ocamlformat/ite-kw_first_no_indicate.ml.ref b/test/passing/refs.ocamlformat/ite-kw_first_no_indicate.ml.ref index 102f8b6d35..1644f1dd7d 100644 --- a/test/passing/refs.ocamlformat/ite-kw_first_no_indicate.ml.ref +++ b/test/passing/refs.ocamlformat/ite-kw_first_no_indicate.ml.ref @@ -221,3 +221,37 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf + then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a + then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> + f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa + then + if bbbbb + then + (* in this case, b <- s *) + if abs_float fa < abs_float fs + then iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.ocamlformat/ite-no_indicate.ml.err b/test/passing/refs.ocamlformat/ite-no_indicate.ml.err index 3695ee88f0..e4933e5313 100644 --- a/test/passing/refs.ocamlformat/ite-no_indicate.ml.err +++ b/test/passing/refs.ocamlformat/ite-no_indicate.ml.err @@ -1,3 +1,5 @@ Warning: ite-no_indicate.ml:89 exceeds the margin Warning: ite-no_indicate.ml:94 exceeds the margin Warning: ite-no_indicate.ml:99 exceeds the margin +Warning: ite-no_indicate.ml:200 exceeds the margin +Warning: ite-no_indicate.ml:209 exceeds the margin diff --git a/test/passing/refs.ocamlformat/ite-no_indicate.ml.ref b/test/passing/refs.ocamlformat/ite-no_indicate.ml.ref index c5d4d66565..8665872059 100644 --- a/test/passing/refs.ocamlformat/ite-no_indicate.ml.ref +++ b/test/passing/refs.ocamlformat/ite-no_indicate.ml.ref @@ -191,3 +191,31 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/refs.ocamlformat/ite-vertical.ml.err b/test/passing/refs.ocamlformat/ite-vertical.ml.err index e69de29bb2..6d93e7b45d 100644 --- a/test/passing/refs.ocamlformat/ite-vertical.ml.err +++ b/test/passing/refs.ocamlformat/ite-vertical.ml.err @@ -0,0 +1,2 @@ +Warning: ite-vertical.ml:291 exceeds the margin +Warning: ite-vertical.ml:304 exceeds the margin diff --git a/test/passing/refs.ocamlformat/ite-vertical.ml.ref b/test/passing/refs.ocamlformat/ite-vertical.ml.ref index c84c131e34..8108fa2e00 100644 --- a/test/passing/refs.ocamlformat/ite-vertical.ml.ref +++ b/test/passing/refs.ocamlformat/ite-vertical.ml.ref @@ -282,3 +282,39 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if + a + then + b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then + b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> + f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else + g diff --git a/test/passing/refs.ocamlformat/ite.ml.err b/test/passing/refs.ocamlformat/ite.ml.err index e69de29bb2..f7f18c8543 100644 --- a/test/passing/refs.ocamlformat/ite.ml.err +++ b/test/passing/refs.ocamlformat/ite.ml.err @@ -0,0 +1,2 @@ +Warning: ite.ml:203 exceeds the margin +Warning: ite.ml:212 exceeds the margin diff --git a/test/passing/refs.ocamlformat/ite.ml.ref b/test/passing/refs.ocamlformat/ite.ml.ref index a91002de0b..4860d9f001 100644 --- a/test/passing/refs.ocamlformat/ite.ml.ref +++ b/test/passing/refs.ocamlformat/ite.ml.ref @@ -194,3 +194,31 @@ let test = (* comment *) 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + begin if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g diff --git a/test/passing/tests/ite.ml b/test/passing/tests/ite.ml index 34f4e8d563..0bdab6413b 100644 --- a/test/passing/tests/ite.ml +++ b/test/passing/tests/ite.ml @@ -197,3 +197,33 @@ let test = 1 else 2 + +(* Begin-end with long comment before nested if (regression test for + formatting oscillation) *) +let f = + match x with + | A -> + if gf then begin + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + if a then b + end + +(* Long comment before match in else branch (regression test for + formatting oscillation) *) +let _ = + if a then b + else + (* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *) + match x with + | A -> f + +(* Comment before nested if in then branch - Compact mode oscillation *) +let _ = + if aaaa then + if bbbbb then + (* in this case, b <- s *) + if abs_float fa < abs_float fs then + iter (i + 1) ~a:s ~b:a ~c:b ~d:c ~fa:fs ~fb:fa ~fc:fb mflag + else + iter (i + 1) ~a ~b:s ~c:b ~d:c ~fa ~fb:fs ~fc:fb mflag + else g