fix: partially completed last words not being counted in custom timed mode

This commit is contained in:
Miodec 2025-07-27 18:33:33 +02:00
parent 0ee4b2960a
commit 28c1cccd57

View file

@ -7,6 +7,7 @@ import * as TestState from "./test-state";
import * as Numbers from "@monkeytype/util/numbers";
import { CompletedEvent, IncompleteTest } from "@monkeytype/schemas/results";
import { isFunboxActiveWithProperty } from "./funbox/list";
import * as CustomText from "./custom-text";
type CharCount = {
spaces: number;
@ -343,7 +344,11 @@ function countChars(): CharCount {
}
correctChars += toAdd.correct;
incorrectChars += toAdd.incorrect;
if (i === inputWords.length - 1 && Config.mode === "time") {
if (
i === inputWords.length - 1 &&
(Config.mode === "time" ||
(Config.mode === "custom" && CustomText.getLimit().mode === "time"))
) {
//last word - check if it was all correct - add to correct word chars
if (toAdd.incorrect === 0) correctWordChars += toAdd.correct;
} else {