Skip to content

yamlfmt is unstable with folded block scalars starting with the [ character #264

Description

@svix-jbrown

This is incredibly bizarre. If you have a folded block scalar (denoted with >) and the first character is a [, yamlfmt becomes unstable and adds an additional newline each time the tool is run

Given the initial input of

key: >
  [
    This is not YAML
  ]

Running yamlfmt on this once yields

key: >
  [

    This is not YAML
  ]

Running it again yields

key: >
  [


    This is not YAML
  ]

and so on.

This doesn't happen if it's an unfolded scalar (i.e., if the first line of my example is key: |) and it doesn't happen for any other first lines in the string (at least, not any I tried).

I can't imagine why the parser would care at all what the contents of a string literal are, but it sure seems to.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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