Problem
cfv collapses short JSON arrays to a single line when they fit within printWidth:
"brackets": [["{", "}"], ["[", "]"], ["(", ")"]],
The correct behavior is to always expand non-empty arrays (one element per line):
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
Empty arrays [] and empty objects {} stay on one line. Everything else expands.
Reproduction
Create a file test.json:
{"brackets": [["{", "}"], ["[", "]"], ["(", ")"]],"other": [1, 2, 3]}
Run:
cfv format --fix --no-config test.json
cat test.json
Actual: inner arrays collapse to [["{", "}"], ...] on one line.
Expected: each inner array on its own line.
Root cause
pkg/formatter/jsoncfmt/jsonc.go — isInlineArray returns true when prefixLen + valLen <= maxLineWidth. This logic should be removed for JSON arrays. Non-empty arrays always expand.
Problem
cfv collapses short JSON arrays to a single line when they fit within
printWidth:The correct behavior is to always expand non-empty arrays (one element per line):
Empty arrays
[]and empty objects{}stay on one line. Everything else expands.Reproduction
Create a file
test.json:{"brackets": [["{", "}"], ["[", "]"], ["(", ")"]],"other": [1, 2, 3]}Run:
Actual: inner arrays collapse to
[["{", "}"], ...]on one line.Expected: each inner array on its own line.
Root cause
pkg/formatter/jsoncfmt/jsonc.go—isInlineArrayreturns true whenprefixLen + valLen <= maxLineWidth. This logic should be removed for JSON arrays. Non-empty arrays always expand.