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

no apparent way to turn off folding for long flow mappings #446

Closed
SIGSTACKFAULT opened this issue Mar 1, 2023 · 3 comments
Closed

no apparent way to turn off folding for long flow mappings #446

SIGSTACKFAULT opened this issue Mar 1, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@SIGSTACKFAULT
Copy link

Describe the bug
I want to have a list of mappings, each one on it's own line.
the library puts long ones on multiple lines and there appears to be no way to control this.

To Reproduce

const yaml = require("yaml")

const doc = new yaml.Document({
    foo: []
});

let node1 = doc.createNode({a:1,b:2,c:3})
let node2 = doc.createNode({d:1,e:2,f:3,g:4,h:8,i:9,j:10,k:11,l:12,m:13})

node1.flow = node2.flow = true

doc.addIn(["foo"], node1)
doc.addIn(["foo"], node2)

console.log(doc.toString());

observe output:

$ node yaml-bug.js
foo:
  - { a: 1, b: 2, c: 3 }
  - {
      d: 1,
      e: 2,
      f: 3,
      g: 4,
      h: 8,
      i: 9,
      j: 10,
      k: 11,
      l: 12,
      m: 13
    }

Expected behaviour
i don't expect this to be the default but there should be a way to do it

$ node yaml-bug.js
foo:
  - { a: 1, b: 2, c: 3 }
  - { d: 1, e: 2, f: 3, g: 4, h: 8, i: 9, j: 10, k: 11, l: 12, m: 13 }

Versions

  • Node: 19.6.0
  • yaml: 2.2.1
@SIGSTACKFAULT SIGSTACKFAULT added the bug Something isn't working label Mar 1, 2023
@eemeli
Copy link
Owner

eemeli commented Mar 1, 2023

It's pretty ugly, but setting this value will get you the results you're looking for:

import { YAMLMap } from 'yaml'

Object.getPrototypeOf(YAMLMap).maxFlowStringSingleLineLength = 2000 // or any other large number

As no-one before now has asked for this, I'm going to hold off on making this more ergonomic until there's a bit more interest. In other words, if this is functionality that you'd use if it was more easily available, please add a comment on this issue.

@eemeli eemeli added enhancement New feature or request and removed bug Something isn't working labels Mar 1, 2023
@SIGSTACKFAULT
Copy link
Author

that works for now!

when this gets fixed properly i'll use the proper solution :3

@eemeli
Copy link
Owner

eemeli commented May 23, 2023

I just realised that this is a duplicate of #421.

@eemeli eemeli closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants