Skip to content

org.openrewrite.yaml.MergeYaml is not respecting the current indentation of the list #5083

Open
@johnsterken

Description

When merging into an existing list with no indentation, the modified entry will be indented, causing the new list to be invalid

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v8.47.1
  • Maven plugin v6.2.0

What is the smallest, simplest way to reproduce the problem?

I wrote a unit test to reproduce the issue

class MergeYamlTest implements RewriteTest {
    ...
    @Test
    void mergeListRespectIndentation() {
        rewriteRun(spec ->
            spec.recipe(new MergeYaml(
              "$",
              //language=yaml
              """
                widget:
                  list:
                  - item 2
                """,
              false,
              null,
              null,
              null,
              null
            )),
          yaml(
            """
              widget:
                list:
                - item 1
              """,
            """
              widget:
                list:
                - item 1
                - item 2
              """
          )
        );
    }
    ...
}

What did you expect to see?

 widget:
   list:
   - item 1
   - item 2

What did you see instead?

widget:
    list:
    - item 1
      - item 2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    • Status

      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions