Skip to content

Comment on multiline map key is moved to value #301

Description

@d-enk

Description

When formatting YAML that uses a multiline block scalar as a map key, comments attached to the key are not preserved.


Reproduction

Input:

? | # comment
  multi
  line
  key
: value

After yamlfmt:

? |
  multi
  line
  key
: value # comment

The comment originally associated with the multiline key (? |) is moved to the value line.


Expected behavior

The comment should remain attached to the multiline key, or the formatter should report that this construct is unsupported instead of silently moving the comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    yaml_v3_problemA bug in the underlying yaml library. These issues are vastly harder to fix.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions