mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-04 06:24:07 +08:00
fix(typing): limit word length using input length, not char index
This fixes an issue where long korean words would not be finishable. Char index includes compose characters, meaning the word was stopped too early. This will very likely close #4389
This commit is contained in:
parent
17c5eecf56
commit
69961185e0
1 changed files with 9 additions and 1 deletions
|
|
@ -43,6 +43,8 @@ const wordsInput = document.getElementById("wordsInput") as HTMLInputElement;
|
|||
const koInputVisual = document.getElementById("koInputVisual") as HTMLElement;
|
||||
|
||||
function setWordsInput(value: string): void {
|
||||
console.log("setting words input to", value);
|
||||
|
||||
// Only change #wordsInput if it's not already the wanted value
|
||||
// Avoids Safari triggering unneeded events, causing issues with
|
||||
// dead keys.
|
||||
|
|
@ -615,12 +617,18 @@ function handleChar(
|
|||
}
|
||||
|
||||
//max length of the input is 20 unless in zen mode then its 30
|
||||
console.log("char index", charIndex);
|
||||
console.log("res word len", resultingWord.length);
|
||||
console.log("cur word len", TestWords.words.getCurrent().length);
|
||||
|
||||
if (
|
||||
(Config.mode === "zen" && charIndex < 30) ||
|
||||
(Config.mode !== "zen" &&
|
||||
charIndex < TestWords.words.getCurrent().length + 20)
|
||||
resultingWord.length < TestWords.words.getCurrent().length + 20)
|
||||
) {
|
||||
TestInput.input.current = resultingWord;
|
||||
} else {
|
||||
console.error("Hitting word limit");
|
||||
}
|
||||
|
||||
if (!thisCharCorrect && Config.difficulty === "master") {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue