From 65b3c1c1e4f751fc863affaaf5c6a29d2e5b237a Mon Sep 17 00:00:00 2001 From: Miodec Date: Fri, 1 Oct 2021 14:02:08 +0100 Subject: [PATCH] fixed enter inserting a ghost character when typed incorrectly --- src/js/input-controller.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/js/input-controller.js b/src/js/input-controller.js index b173c07b0..599538ee3 100644 --- a/src/js/input-controller.js +++ b/src/js/input-controller.js @@ -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" &&