- if (current_display_line !== null) {
- highlighted_move = $("#automove" + current_display_line.line_number + "-" + current_display_move);
- highlighted_move.addClass('highlight');
+ if (current_display_line) {
+ // See if the current displayed line is identical to any of the ones
+ // we have on screen. (It might not be if e.g. the analysis reloaded
+ // since we started looking.)
+ for (var i = 0; i < display_lines.length; ++i) {
+ var line = display_lines[i];
+ if (current_display_line.start_fen !== line.start_fen) continue;
+ if (current_display_line.pretty_pv.length !== line.pretty_pv.length) continue;
+ var ok = true;
+ for (var j = 0; j < line.pretty_pv.length; ++j) {
+ if (current_display_line.pretty_pv[j] !== line.pretty_pv[j]) {
+ ok = false;
+ break;
+ }
+ }
+ if (ok) {
+ highlighted_move = $("#automove" + i + "-" + current_display_move);
+ highlighted_move.addClass('highlight');
+ break;
+ }
+ }