fixed enter inserting a ghost character when typed incorrectly

This commit is contained in:
Miodec 2021-10-01 14:02:08 +01:00
parent 874e5cbebe
commit 65b3c1c1e4

View file

@ -440,10 +440,6 @@ function handleChar(char, charIndex) {
return;
}
if (TestLogic.input.current === "") {
TestStats.setBurstStart(performance.now());
}
Focus.set(true);
Caret.stopAnimation();
@ -453,6 +449,15 @@ function handleChar(char, charIndex) {
char = TestLogic.words.getCurrent().charAt(charIndex);
}
if (!thisCharCorrect && char === "\n") {
if (TestLogic.input.current === "") return;
char = " ";
}
if (TestLogic.input.current === "") {
TestStats.setBurstStart(performance.now());
}
const resultingWord =
TestLogic.input.current.substring(0, charIndex) +
char +
@ -577,7 +582,6 @@ function handleChar(char, charIndex) {
let activeWordTopBeforeJump = document.querySelector("#words .word.active")
.offsetTop;
TestUI.updateWordElement();
if (!Config.hideExtraLetters) {
let newActiveTop = document.querySelector("#words .word.active").offsetTop;
@ -596,11 +600,12 @@ function handleChar(char, charIndex) {
if (!Config.showAllLines) TestUI.lineJump(currentTop);
} else {
TestLogic.input.current = TestLogic.input.current.slice(0, -1);
TestUI.updateWordElement();
}
}
}
TestUI.updateWordElement();
//simulate space press in nospace funbox
if (
(Config.funbox === "nospace" &&