Skip to content

Bug: "long but not long enough" doc comments mess with type attributes #1049

@clembu

Description

@clembu

Describe the bug

"Not long enough" doc-comments make the type attribute's closing bracket wrap to the next line, along with the wrapping parenthesis, but indented really close to the margin

How to Reproduce

(in the following snippets, the margin is indicated with a commented pipe below the declaration, those comments are irrelevant to the issue)

This snippet causes the issue:

type t =
  ([ `foo
   | `bar  (** 58 chars.................................................. *) ][@js.enum
                                                                       ])
                                                                             (* | *)

This one doesn't (included for comparison with expected output)

type t =
  ([ `foo
   | `bar  (** 59 chars................................................... *)
   ][@js.enum])
                                                                             (* | *)

Config

Ocamlformat config file:

break-cases = fit
break-collection-expressions = wrap
break-fun-decl = wrap
break-infix = wrap
break-infix-before-func = false
break-separators = after-and-docked
break-string-literals = never
break-struct = force
doc-comments = after
extension-sugar = preserve
indicate-multiline-delimiters = no
infix-precedence = indent
let-and = compact
let-binding-spacing = compact
let-open = auto
module-item-spacing = compact
parens-tuple = multi-line-only
parens-tuple-patterns = multi-line-only
sequence-style = terminator
single-case = compact
type-decl = compact
if-then-else = keyword-first
field-space = loose
ocp-indent-compat = true
wrap-comments = true
parse-docstrings = true
align-variants-decl = true

Margin is at 80

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions