Skip to content

impl: DirectionWriter ignores orderedComponents — interleaved direction-type children lose original order on write #206

Description

@webern

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    aiIssues opened by, or through, a coding agent.area/mx::implbugsoftware defectnon-breakingfixes or implementation that do not require breaking changes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions