From 8b950782231b3565860ea27d5d124e9feaecd8fa Mon Sep 17 00:00:00 2001 From: Miodec Date: Sun, 13 Aug 2023 01:21:03 +0200 Subject: [PATCH] impr(test): stop on letter now supports indicate typos The typos will now be correctly shown to the right of the caret --- frontend/src/ts/controllers/input-controller.ts | 6 ++++++ frontend/src/ts/test/test-ui.ts | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index 5e0c92603..01013473a 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -192,6 +192,9 @@ function handleSpace(): void { MonkeyPower.addPower(isWordCorrect, true); TestInput.incrementAccuracy(isWordCorrect); if (isWordCorrect) { + if (Config.indicateTypos !== "off" && Config.stopOnError === "letter") { + TestUI.updateWordElement(); + } PaceCaret.handleSpace(true, currentWord); TestInput.input.pushHistory(); TestWords.words.increaseCurrentIndex(); @@ -590,6 +593,9 @@ function handleChar( Config.stopOnError === "letter" && !thisCharCorrect ) { + if (Config.indicateTypos !== "off") { + TestUI.updateWordElement(undefined, TestInput.input.current + char); + } return; } diff --git a/frontend/src/ts/test/test-ui.ts b/frontend/src/ts/test/test-ui.ts index 497ad59ec..4376c49cc 100644 --- a/frontend/src/ts/test/test-ui.ts +++ b/frontend/src/ts/test/test-ui.ts @@ -536,8 +536,11 @@ export async function screenshot(): Promise { }, 3000); } -export function updateWordElement(showError = !Config.blindMode): void { - const input = TestInput.input.current; +export function updateWordElement( + showError = !Config.blindMode, + inputOverride?: string +): void { + const input = inputOverride || TestInput.input.current; const wordAtIndex = document.querySelector("#words .word.active"); const currentWord = TestWords.words.getCurrent(); if (!currentWord && Config.mode !== "zen") return;