Skip to content

Commit e1027ea

Browse files
authored
Remove line break in 'M with module N = N (* cmt *)' (#2779)
Improve the formatting of: module type of M with module A = A (*test*)
1 parent c2d5c41 commit e1027ea

10 files changed

Lines changed: 19 additions & 24 deletions

File tree

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ profile. This started with version 0.26.0.
6363
instead of only some.
6464
(#2737, @v-gb)
6565

66+
- Remove line break in `M with module N = N (* cmt *)` (#2779, @Julow)
67+
6668
### Internal
6769

6870
- Added information on writing tests to `CONTRIBUTING.md` (#2838, @WardBrian)

lib/Fmt_ast.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ let rec fmt_longident c (li : Longident.t) =
262262
$ wrap (cut_break $ str "(") (str ")") (fmt_longident_loc c li2) )
263263

264264
and fmt_longident_loc c ?pre {txt; loc} =
265-
Cmts.fmt c loc (opt pre str $ fmt_longident c txt)
265+
let box = if Cmts.has_after c.cmts loc then hvbox 0 else Fn.id in
266+
box (Cmts.fmt c loc (opt pre str $ fmt_longident c txt))
266267

267268
let str_longident c x =
268269
Format_.asprintf "%a" (fun fs x -> eval fs (fmt_longident c x)) x
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Warning: module_type.ml:38 exceeds the margin
2-
Warning: module_type.ml:77 exceeds the margin
1+
Warning: module_type.ml:36 exceeds the margin
2+
Warning: module_type.ml:75 exceeds the margin

test/passing/refs.ahrefs/module_type.ml.ref

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ end
2626

2727
module type M =
2828
module type of M
29-
with module A := A
30-
(*test*)
31-
and module A = A
32-
(*test*)
29+
with module A := A (*test*)
30+
and module A = A (*test*)
3331
and module A = A
3432
with module A = A
3533
(*test*)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Warning: module_type.ml:35 exceeds the margin
2-
Warning: module_type.ml:71 exceeds the margin
1+
Warning: module_type.ml:33 exceeds the margin
2+
Warning: module_type.ml:69 exceeds the margin

test/passing/refs.default/module_type.ml.ref

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ end
2323

2424
module type M =
2525
module type of M
26-
with module A := A
27-
(*test*)
28-
and module A = A
29-
(*test*)
26+
with module A := A (*test*)
27+
and module A = A (*test*)
3028
and module A = A
3129
with module A = A
3230
(*test*)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Warning: module_type.ml:36 exceeds the margin
1+
Warning: module_type.ml:34 exceeds the margin

test/passing/refs.janestreet/module_type.ml.ref

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ end
2424

2525
module type M =
2626
module type of M
27-
with module A := A
28-
(*test*)
29-
and module A = A
30-
(*test*)
27+
with module A := A (*test*)
28+
and module A = A (*test*)
3129
and module A = A
3230
with module A = A
3331
(*test*)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Warning: module_type.ml:38 exceeds the margin
2-
Warning: module_type.ml:75 exceeds the margin
1+
Warning: module_type.ml:36 exceeds the margin
2+
Warning: module_type.ml:73 exceeds the margin

test/passing/refs.ocamlformat/module_type.ml.ref

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ end
2626

2727
module type M =
2828
module type of M
29-
with module A := A
30-
(*test*)
31-
and module A = A
32-
(*test*)
29+
with module A := A (*test*)
30+
and module A = A (*test*)
3331
and module A = A
3432
with module A = A
3533
(*test*)

0 commit comments

Comments
 (0)