Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3: idempotency in file formatter #649

Open
mtojek opened this issue Aug 19, 2020 · 2 comments
Open

v3: idempotency in file formatter #649

mtojek opened this issue Aug 19, 2020 · 2 comments

Comments

@mtojek
Copy link

mtojek commented Aug 19, 2020

Hi,

I planned to adopt go-yaml/yaml.v3 in a small YAML formatter (simple "unmarshal and marshal"). It looks to work great with yaml.Node, it preserves comments, field ordering, but fails with the following pattern:

- first:
    second: >-
      aaaa
        bbbb
          cccc

The outcome of formatting is:

- first:
    second: >-
      aaaa

        bbbb
          cccc

What is more, formatting such file twice gives even worse output:

- first:
    second: >-
      aaaa


        bbbb
          cccc

(double new line)

I wonder if I can use the library to implement a formatter.

BTW It would be great to increase the control over rendering, e.g. total line length, fields stored in memory as is (use case: I don't want to format this field).

@felixfontein
Copy link

I can reproduce this, but I'm not sure how to fix this. The code which causes this is identical to the corresponding code in libyaml (and hasn't changed for many years).

@calebAtIspot
Copy link

idempotency would be great as it would help fix mikefarah/yq#465

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants