yq/pkg
Jacob Heider b78119772a
Preserve TOML comments on arrays of tables and array items
Two comment-fidelity bugs in the TOML round-trip:

- A head comment directly above an [[array-of-tables]] header was
  dropped. The decoder attaches it correctly, but the three encoder
  loops that emit [[...]] headers never wrote it, unlike the [table]
  path. Emit each element's head comment before its header.

- An inline (trailing) comment on an array item detached and floated
  onto its own line as a head comment on the next item, with a spurious
  blank line. createArray treated every in-array comment as a head
  comment for the next element; use the parser's byte ranges to detect a
  same-line trailing comment and attach it as a line comment on the
  current item instead. The encoder now emits array-item line comments
  inline and only inserts a blank line before head-commented elements.

Adds round-trip tests for both cases.
2026-07-04 19:15:53 -04:00
..
yqlib Preserve TOML comments on arrays of tables and array items 2026-07-04 19:15:53 -04:00