DirectionReader records the original element order in DirectionData::orderedComponents (a vector<DirectionComponent> of {kind, index} pairs). DirectionWriter never consults it — it emits each component kind in its own if block (currently: metronome, then words; PR #203 adds segnos then codas).
When a <direction> in the source file interleaves different <direction-type> children — e.g. <segno/>, <words>A</words>, <coda/> — the writer will reorder them to <segno/>, <coda/>, <words>A</words>, breaking the round-trip.
Fix
Replace the per-kind emission loops with a single loop over orderedComponents that dispatches to a per-kind emit helper. This is how the reader already works — parseDirectionType dispatches by kind and calls appendOrderedComponent after each one.
Pre-existing limitation, surfaced and documented by PR #203.
A successful fix must include red/green tests to prove the before and after state.
References
DirectionReaderrecords the original element order inDirectionData::orderedComponents(avector<DirectionComponent>of{kind, index}pairs).DirectionWriternever consults it — it emits each component kind in its ownifblock (currently: metronome, then words; PR #203 adds segnos then codas).When a
<direction>in the source file interleaves different<direction-type>children — e.g.<segno/>,<words>A</words>,<coda/>— the writer will reorder them to<segno/>,<coda/>,<words>A</words>, breaking the round-trip.Fix
Replace the per-kind emission loops with a single loop over
orderedComponentsthat dispatches to a per-kind emit helper. This is how the reader already works —parseDirectionTypedispatches by kind and callsappendOrderedComponentafter each one.Pre-existing limitation, surfaced and documented by PR #203.
A successful fix must include red/green tests to prove the before and after state.
References