From f53ed4f5b41f4e323994c043324285ede63cd0e5 Mon Sep 17 00:00:00 2001 From: Miodec Date: Sun, 20 Jun 2021 14:54:29 +0100 Subject: [PATCH] fixed infinite loop when practising missed words. closes #1558 --- src/js/test/test-logic.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/js/test/test-logic.js b/src/js/test/test-logic.js index a8a6a4cf2..346ebc9a0 100644 --- a/src/js/test/test-logic.js +++ b/src/js/test/test-logic.js @@ -468,24 +468,24 @@ export async function init() { const previousWord = words.get(i - 1); const previousWord2 = words.get(i - 2); if ( - Config.mode == "custom" && - (CustomText.isWordRandom || CustomText.isTimeRandom) && - wordset.length < 3 - ) { - randomWord = wordset[Math.floor(Math.random() * wordset.length)]; - } else if ( Config.mode == "custom" && !CustomText.isWordRandom && !CustomText.isTimeRandom ) { randomWord = CustomText.text[i]; - } else { + } else if ( + Config.mode == "custom" && + (wordset.length < 3 || PractiseMissed.before.mode !== null) + ) { + randomWord = wordset[Math.floor(Math.random() * wordset.length)]; + } else { while ( randomWord == previousWord || randomWord == previousWord2 || (!Config.punctuation && randomWord == "I") || randomWord.indexOf(" ") > -1 ) { + console.log('rerandomising'); randomWord = wordset[Math.floor(Math.random() * wordset.length)]; } }