Skip to content

Commit fd8001c

Browse files
authored
fix(custom-text): Reset long custom text progress to start of word (@Leonabcd123) (monkeytypegame#7213)
### Description Check if the user bailed out mid word, if so decrease `historyLength` by 1 to reset to the start of the current word instead of the start of the next word.
1 parent 38f3fc2 commit fd8001c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

frontend/src/ts/test/test-logic.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,16 @@ export async function finish(difficultyFailed = false): Promise<void> {
10841084
) {
10851085
// They bailed out
10861086

1087-
const historyLength = TestInput.input.getHistory()?.length;
1087+
const history = TestInput.input.getHistory();
1088+
let historyLength = history?.length;
1089+
const wordIndex = historyLength - 1;
1090+
1091+
const lastWordInputLength = history[wordIndex]?.length ?? 0;
1092+
1093+
if (lastWordInputLength < TestWords.words.get(wordIndex).length) {
1094+
historyLength--;
1095+
}
1096+
10881097
const newProgress =
10891098
CustomText.getCustomTextLongProgress(customTextName) + historyLength;
10901099
CustomText.setCustomTextLongProgress(customTextName, newProgress);

0 commit comments

Comments
 (0)