mirror of
https://github.com/github/spec-kit.git
synced 2026-08-03 06:26:30 +08:00
_traverse_and_apply's insert_after loop iterated reversed(edits) over the flat per-anchor edit list. The reversal is only meant to place a higher-priority OVERLAY closer to the anchor (mirroring insert_before's winner-closest behaviour), but reversing the flat list also flipped the declared order of multiple insert_after edits authored within a SINGLE overlay: [insert_after a->x, insert_after a->y] produced [a, y, x, b] instead of [a, x, y, b]. insert_before (a forward loop) already preserves order, so the two operations were asymmetric. Group contiguous same-layer edits and reverse the GROUP order only, keeping each overlay's own inserts in declared order. Cross-overlay priority is unchanged (higher-priority overlay still lands closest to the anchor). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>