rewrite icon indicating copy to clipboard operation
rewrite copied to clipboard

fix: `MergeYaml` block indentation not as expected

Open pstreef opened this issue 7 months ago • 0 comments

I think I have identified a bug in the yaml parser + writer. when we parse the following yaml:

some:
  object:
    script: |
      #!/bin/bash
      echo "hello

the value of the script mapping is:

      #!/bin/bash
      echo "hello

when writing this yaml it correctly writes back as the original because of this. However, when we want to insert this yaml somewhere into another document the prefix is not taken into account. So if I were to insert

script: |
  #!/bin/bash
  echo "hello

into the same spot I end up with:

some:
  object:
    script: |
  #!/bin/bash
  echo "hello

I think we should remove the whitespace from the block values and use the prefix of the parent (in case of a LITERAL or FOLDER style scalar) to indent when printing

It might be better to add the current indentation to the printer context.

pstreef avatar Jul 25 '24 19:07 pstreef