Skip to content

Commit a1e0da8

Browse files
committed
fix(custom text): generating not enough words in some cases when using pipe delimiter
part of monkeytypegame#6403
1 parent a5dc0d6 commit a1e0da8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

frontend/src/ts/test/words-generator.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,12 @@ export async function generateWords(
657657
ret.sectionIndexes.push(nextWord.sectionIndex);
658658

659659
if (Config.mode === "custom" && CustomText.getPipeDelimiter()) {
660+
//generate a given number of sections, make sure to not cut a section off
660661
const sectionFinishedAndOverLimit =
661-
currentSection.length === 0 &&
662-
sectionIndex >= CustomText.getLimitValue();
663-
if (sectionFinishedAndOverLimit || ret.words.length >= limit) {
662+
currentSection.length === 0 && sectionIndex >= limit;
663+
//make sure we dont go over a hard limit, in cases where the sections are very large
664+
const upperWordLimit = ret.words.length >= 100;
665+
if (sectionFinishedAndOverLimit || upperWordLimit) {
664666
stop = true;
665667
}
666668
} else if (ret.words.length >= limit) {

0 commit comments

Comments
 (0)