ocaml-ppx / ocamlformat

Auto-formatter for OCaml code
MIT License
622 stars 175 forks source link

Bug: `--parse-docstrings` violates margin #2549

Closed mmottl closed 4 months ago

mmottl commented 4 months ago

Describe the bug

Passing --parse-docstrings may lead to output that violates the configured margin.

❯ ocamlformat --version
0.26.2

How to Reproduce

Formatted file foo.ml:

(** xxxxx xx xxxxxx xxxxxx xxxxxx xxxxx xxxxxxx xxx xxxxxx xxx xxxx
    xxxxxxxxxx. *)

Command line (explicitly sets a margin of 80):

ocamlformat --enable-outside-detected-project -m 80 --parse-docstrings foo.ml

Output has an 82 character line:

(** xxxxx xx xxxxxx xxxxxx xxxxxx xxxxx xxxxxxx xxx xxxxxx xxx xxxx xxxxxxxxxx. *)
Julow commented 4 months ago

Thanks for reporting. Should be fixed by https://github.com/ocaml-ppx/ocamlformat/pull/2550