From baaac84e13ddfb274702b7d5f1990caaa67bea28 Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 3 Mar 2022 00:25:52 +0100 Subject: [PATCH] reordered handle char code again --- .../scripts/controllers/input-controller.ts | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/frontend/src/scripts/controllers/input-controller.ts b/frontend/src/scripts/controllers/input-controller.ts index 12262856b..31937454a 100644 --- a/frontend/src/scripts/controllers/input-controller.ts +++ b/frontend/src/scripts/controllers/input-controller.ts @@ -466,22 +466,19 @@ function handleChar(char: string, charIndex: number): void { TestInput.updateLastKeypress(); TestInput.pushKeypressWord(TestWords.words.currentIndex); + if ( + Config.difficulty !== "master" && + Config.stopOnError == "letter" && + !thisCharCorrect + ) { + return; + } + Replay.addReplayEvent( thisCharCorrect ? "correctLetter" : "incorrectLetter", char ); - if (!thisCharCorrect && Config.difficulty == "master") { - TestInput.input.pushHistory(); - TestInput.corrected.pushHistory(); - TestLogic.fail("difficulty"); - return; - } - - if (Config.stopOnError == "letter" && !thisCharCorrect) { - return; - } - //update the active word top, but only once if ( TestInput.input.current.length === 1 && @@ -501,6 +498,13 @@ function handleChar(char: string, charIndex: number): void { TestInput.input.current = resultingWord; } + if (!thisCharCorrect && Config.difficulty == "master") { + TestInput.input.pushHistory(); + TestInput.corrected.pushHistory(); + TestLogic.fail("difficulty"); + return; + } + //keymap if (Config.keymapMode === "react") { Keymap.flashKey(char, thisCharCorrect);