Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Items marked with an asterisk (\*) are changes that are likely to format
existing code differently from the previous release when using the default
profile. This started with version 0.26.0.

## unreleased

### Fixed

- Remove trailing space inside a wrapping empty signature (#2443, @Julow)

## 0.26.1 (2023-09-15)

### Changed
Expand Down
2 changes: 1 addition & 1 deletion lib/Fmt_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3463,7 +3463,7 @@ and fmt_module_type c ?(rec_ = false) ({ast= mty; _} as xmty) =
{ opn= None
; pro= Some (before $ str "sig" $ fmt_if empty " ")
; psp= fmt_if (not empty) "@;<1000 2>"
; bdy= within $ fmt_signature c ctx s
; bdy= (within $ if empty then noop else fmt_signature c ctx s)
; cls= noop
; esp= fmt_if (not empty) "@;<1000 0>"
; epi=
Expand Down
18 changes: 18 additions & 0 deletions test/passing/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3897,6 +3897,24 @@
(package ocamlformat)
(action (diff tests/module_type.ml.err module_type.ml.stderr)))

(rule
(deps tests/.ocamlformat )
(package ocamlformat)
(action
(with-stdout-to module_type.mli.stdout
(with-stderr-to module_type.mli.stderr
(run %{bin:ocamlformat} --margin-check %{dep:tests/module_type.mli})))))

(rule
(alias runtest)
(package ocamlformat)
(action (diff tests/module_type.mli.ref module_type.mli.stdout)))

(rule
(alias runtest)
(package ocamlformat)
(action (diff tests/module_type.mli.err module_type.mli.stderr)))

(rule
(deps tests/.ocamlformat )
(package ocamlformat)
Expand Down
4 changes: 4 additions & 0 deletions test/passing/tests/module_type.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(* Wrapping an empty sig *)
module Foo
(A : FOO)
(B : FOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO) : sig end
1 change: 1 addition & 0 deletions test/passing/tests/module_type.mli.err
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Warning: tests/module_type.mli:3 exceeds the margin
4 changes: 4 additions & 0 deletions test/passing/tests/module_type.mli.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(* Wrapping an empty sig *)
module Foo
(A : FOO)
(B : FOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO) : sig end