fixed infinite loop when practising missed words. closes #1558

This commit is contained in:
Miodec 2021-06-20 14:54:29 +01:00
parent ca4730abae
commit f53ed4f5b4

View file

@ -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)];
}
}