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

Prefer indentation before flow style array nested in mapping. #237

Open
ra1028 opened this issue Dec 17, 2019 · 2 comments
Open

Prefer indentation before flow style array nested in mapping. #237

ra1028 opened this issue Dec 17, 2019 · 2 comments

Comments

@ra1028
Copy link

ra1028 commented Dec 17, 2019

Hi, many thanks for Yams.

I'm using Yams to dump Encodable struct to file via YamlEncoder.
I found a little glitch that the malformed indentation before the flow style array elements that nested in mapping.
This isn't corrupted yaml syntax, but it's preferable to indent it.

Example

struct Test: Encodable {
    var foo: String
    var bar: Int
    var dict: [String: [String]]
}

let test = Test(
    foo: "foo",
    bar: 100,
    dict: [
        "baz": ["A", "B", "C"],
        "qux": ["1", "2"]
    ]
)

print(try YAMLEncoder().encode(test))

Current behavior

foo: foo
bar: 100
dict:
  baz:
  - A
  - B
  - C
  qux:
  - 1
  - 2

Expected

foo: foo
bar: 100
dict:
  baz:
    - A
    - B
    - C
  qux:
    - 1
    - 2

Environments

  • Library version: 2.0.0

  • Swift version: 5.1

  • Xcode version: 11.2.1

@fmgcoelho
Copy link

fmgcoelho commented Jul 12, 2021

yamllint output on the "Current behavior" above:

  1:1       warning  missing document start "---"  (document-start)
  5:3       error    wrong indentation: expected 4 but found 2  (indentation)
  9:3       error    wrong indentation: expected 4 but found 2  (indentation)

@CraigSiemens
Copy link

We've run into this as well. The main issue for us is that the YAML VSCode extension adds the indenting on save but then our tooling removed the indent when it updates the files.

It appears to be an issue with libyaml, which Yams wraps.

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