Skip to content

Commit

Permalink
fix(word generation): A A or A B A word duplicates could sometimes ap…
Browse files Browse the repository at this point in the history
…pear when using lazy mode

closes #5238
  • Loading branch information
Miodec committed Apr 3, 2024
1 parent 72fd518 commit 8755f45
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend/src/ts/test/words-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,10 +737,11 @@ export async function getNextWord(
} else {
let regenarationCount = 0; //infinite loop emergency stop button
let firstAfterSplit = (randomWord.split(" ")[0] as string).toLowerCase();
let firstAfterSplitLazy = applyLazyModeToWord(firstAfterSplit, language);
while (
regenarationCount < 100 &&
(previousWordRaw === firstAfterSplit ||
previousWord2Raw === firstAfterSplit ||
(previousWordRaw === firstAfterSplitLazy ||
previousWord2Raw === firstAfterSplitLazy ||
(Config.mode !== "custom" &&
!Config.punctuation &&
randomWord === "I") ||
Expand All @@ -755,6 +756,7 @@ export async function getNextWord(
regenarationCount++;
randomWord = wordset.randomWord(funboxFrequency);
firstAfterSplit = randomWord.split(" ")[0] as string;
firstAfterSplitLazy = applyLazyModeToWord(firstAfterSplit, language);
}
}
randomWord = randomWord.replace(/ +/g, " ");
Expand Down

0 comments on commit 8755f45

Please sign in to comment.