google / yamlfmt

An extensible command line tool or library to format yaml files.
Apache License 2.0
1.2k stars 48 forks source link

New line issues with comments on Windows with CRLF EOL #192

Open 06393993 opened 4 months ago

06393993 commented 4 months ago

With the following yaml with a proper newline at EOF on Windows:

k:
  - a: 1
    # abcd
    b: 2

yamlfmt seems to always want to add an unnecessary new line after the comment:

PS> del $env:USERPROFILE/go/bin/yamlfmt.exe
PS> go install github.com/google/yamlfmt/cmd/yamlfmt@main
PS> & "$env:USERPROFILE/go/bin/yamlfmt" --version
yamlfmt dev (none)
PS> & "$env:USERPROFILE/go/bin/yamlfmt" -lint test.yaml
The following formatting differences were found:

test.yaml:
  k:          k:
    - a: 1      - a: 1
      # abcd      # abcd
+
      b: 2        b: 2

I don't set up any format configurations. This issue is probably related to #34.