promotion: 'q' // NOTE: always promote to a queen for example simplicity
});
+ // Move ahead on the line we're on -- this includes history if we've
+ // gone backwards.
if (current_display_line &&
current_display_move < current_display_line.pv.length - 1 &&
current_display_line.pv[current_display_move + 1] === move.san) {
// Walk down the displayed lines until we find one that starts with
// this move, then select that. Note that this gives us a good priority
- // order (history first, then PV, then multi-PV lines).
- for (let i = 0; i < display_lines.length; ++i) {
+ // order (PV, then multi-PV lines; history was already dealt with above,
+ // as it's the only line that originates backwards).
+ for (let i = 1; i < display_lines.length; ++i) {
if (i == 1 && current_display_line) {
// Do not choose PV if not on it.
continue;
}
let line = display_lines[i];
if (line.pv[line.start_display_move_num] === move.san) {
- show_line(i, 0);
+ show_line(i, line.start_display_move_num);
return;
}
}