shaack / cm-pgn

Parse and create PGNs (Portable Game Notation for chess games)
MIT License
27 stars 21 forks source link

Fix inconsistent next and previous pointers #21

Closed donkawechico closed 9 months ago

donkawechico commented 11 months ago

See https://github.com/shaack/cm-pgn/issues/20.

Overview

This fixes (what I believe to be) a bug in traverse where a move in the main line will get its next property set to the first move of an alternate line rather than the next move in its own line.

In general, it seems the correct behavior ought to be that every move in move.variation should satisfy

move.variation[0] <--> move.variation[1] <--> move.variation[2] <--> ... <--> move.variation[n]

If one of those moves has variations branching off it, that shouldn't matter to that move's previous and next pointers.