-
Notifications
You must be signed in to change notification settings - Fork 150
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When using the flow collection style, collections always seem to wrap at around 80 characters, regardless of the lineWidth option:
blockCollection:
aKey: hello
anotherKey: world
yetAnotherKey: "!!!"
listOfFlowCollection:
- {
aKey: hello,
anotherKey: world,
yetAnotherKey: "!!!",
oneMoreKey: "!!!!!!!!"
}
- {
aKey: hello,
anotherKey: world,
yetAnotherKey: "!!!",
oneMoreKey: "!!!!!!!!"
}
flowColTwo:
- { aKey: hello, bKey: world, cKey: "!!!" }
- { aKey: hello, bKey: world, cKey: "!!!" }
- { aKey: hello, bKey: world, cKey: "!!!", dKey: "!" }To Reproduce
function serialize() {
const doc = new YAML.Document({
blockCollection: {
aKey: 'hello',
anotherKey: 'world',
yetAnotherKey: '!!!'
},
listOfFlowCollection: [
{ aKey: 'hello', anotherKey: 'world', yetAnotherKey: '!!!', oneMoreKey: '!!!!!!!!' },
{ aKey: 'hello', anotherKey: 'world', yetAnotherKey: '!!!', oneMoreKey: '!!!!!!!!' },
],
flowColTwo: [
{ aKey: 'hello', bKey: 'world', cKey: '!!!' },
{ aKey: 'hello', bKey: 'world', cKey: '!!!' },
{ aKey: 'hello', bKey: 'world', cKey: '!!!', dKey: '!' },
]
})
YAML.visit(doc, {
Pair(_, pair: any) {
if (pair.key?.value === 'listOfFlowCollection' || pair.key?.value === 'flowColTwo') {
for (const i of pair.value.items) {
i.flow = true
}
}
}
})
return doc.toString({ lineWidth: 120 })
}Expected behaviour
Flow collections respect the lineWidth option and wrap at 120 characters instead of 80 (or not wrap at all if lineWidth is 0)
blockCollection:
aKey: hello
anotherKey: world
yetAnotherKey: "!!!"
listOfFlowCollection:
- { aKey: hello, anotherKey: world, yetAnotherKey: "!!!", oneMoreKey: "!!!!!!!!" }
- { aKey: hello, anotherKey: world, yetAnotherKey: "!!!", oneMoreKey: "!!!!!!!!" }
flowColTwo:
- { aKey: hello, bKey: world, cKey: "!!!" }
- { aKey: hello, bKey: world, cKey: "!!!" }
- { aKey: hello, bKey: world, cKey: "!!!", dKey: "!" }Versions (please complete the following information):
- Environment: Chrome 119.0.6045.159
yaml: 2.3.4
Additional context
The same issue manifests when using collectionStyle: 'flow' in the toString() options, so it's not specific to mixed style.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working