Skip to content

Commit

Permalink
Fix unecessary break due to comment in polymorphic variants (#2606)
Browse files Browse the repository at this point in the history
The previous formatting was:

    | (* Other inline element markup. *)
      `Simple_reference of
      string
  • Loading branch information
Julow authored Oct 31, 2024
1 parent 0df6987 commit 7ebe9fc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ profile. This started with version 0.26.0.
- \* Consistent break after string constant argument (#2453, @Julow)
- \* Fix cinaps comment formatting to not change multiline string contents (#2463, @tdelvecchio-jsc)
- \* Fix the indentation of tuples in attributes and extensions (#2488, @Julow)
- \* Fix unwanted alignment after comment (#2507, #2589, @Julow)
- \* Fix weird indentation and line breaks after comments (#2507, #2589, #2606, @Julow)
- \* Fix unwanted alignment in if-then-else (#2511, @Julow)
- Fix missing parentheses around constraint expressions with attributes (#2513, @alanechang)
- Fix formatting of type vars in GADT constructors (#2518, @Julow)
Expand Down
2 changes: 1 addition & 1 deletion lib/Fmt_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ and fmt_row_field c ctx {prf_desc; prf_attributes; prf_loc} =
| Rinherit typ -> fmt_core_type c (sub_typ ~ctx typ)
in
hvbox 0
( hvbox (Params.Indent.variant_type_arg c.conf) (Cmts.fmt c prf_loc row)
( Cmts.fmt c prf_loc (hvbox (Params.Indent.variant_type_arg c.conf) row)
$ fmt_attributes_and_docstrings c prf_attributes )

and fmt_pattern_attributes c xpat k =
Expand Down
6 changes: 6 additions & 0 deletions test/passing/tests/variants.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ let _ = (* xx *) `(* yy *) A (* zz *)
let _ = (* xx *) `B (* zz *)

let _ = `(* yy *) C (* zz *)

type t =
[ `Fooooo
| (* Other inline element markup. *)
`Simple_reference of string
| `Fooooo ]

0 comments on commit 7ebe9fc

Please sign in to comment.