From e43b27a286ab900c6e609398e89a2b5a1f180e47 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sun, 31 May 2026 20:03:55 +0300 Subject: [PATCH 1/2] fix(nospace): don't move to next word when removing last character --- frontend/src/ts/input/handlers/insert-text.ts | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/frontend/src/ts/input/handlers/insert-text.ts b/frontend/src/ts/input/handlers/insert-text.ts index 6145641c5a49..bae539777552 100644 --- a/frontend/src/ts/input/handlers/insert-text.ts +++ b/frontend/src/ts/input/handlers/insert-text.ts @@ -149,12 +149,39 @@ export async function onInsertText(options: OnInsertTextParams): Promise { correctShiftUsed, }); + // handing cases where last char needs to be removed + // this is here and not in beforeInsertText because we want to penalize for incorrect spaces + // like accuracy, keypress errors, and missed words + let removeLastChar = false; + let visualInputOverride: string | undefined; + if (Config.stopOnError === "letter" && !correct) { + if (!Config.blindMode) { + visualInputOverride = testInput + data; + } + removeLastChar = true; + } + + if (!isSpace(data) && correctShiftUsed === false) { + removeLastChar = true; + visualInputOverride = undefined; + incrementIncorrectShiftsInARow(); + if (getIncorrectShiftsInARow() >= 5) { + showNoticeNotification("Opposite shift mode is on.", { + important: true, + customTitle: "Reminder", + }); + } + } else { + resetIncorrectShiftsInARow(); + } + // word navigation check const noSpaceForce = isFunboxActiveWithProperty("nospace") && (testInput + data).length === TestWords.words.getCurrentText().length; const shouldGoToNextWord = - ((charIsSpace || charIsNewline) && !shouldInsertSpace) || noSpaceForce; + (((charIsSpace || charIsNewline) && !shouldInsertSpace) || noSpaceForce) && + !removeLastChar; // update test input state if (!charIsSpace || shouldInsertSpace) { @@ -182,32 +209,6 @@ export async function onInsertText(options: OnInsertTextParams): Promise { TestInput.corrected.update(data, correct); } - // handing cases where last char needs to be removed - // this is here and not in beforeInsertText because we want to penalize for incorrect spaces - // like accuracy, keypress errors, and missed words - let removeLastChar = false; - let visualInputOverride: string | undefined; - if (Config.stopOnError === "letter" && !correct) { - if (!Config.blindMode) { - visualInputOverride = testInput + data; - } - removeLastChar = true; - } - - if (!isSpace(data) && correctShiftUsed === false) { - removeLastChar = true; - visualInputOverride = undefined; - incrementIncorrectShiftsInARow(); - if (getIncorrectShiftsInARow() >= 5) { - showNoticeNotification("Opposite shift mode is on.", { - important: true, - customTitle: "Reminder", - }); - } - } else { - resetIncorrectShiftsInARow(); - } - if (removeLastChar) { replaceInputElementLastValueChar(""); TestInput.input.syncWithInputElement(); From 202f6c9479bbd33377631c5f754cf0a099a92cf6 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Sun, 31 May 2026 21:19:30 +0300 Subject: [PATCH 2/2] Order --- frontend/src/ts/input/handlers/insert-text.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/ts/input/handlers/insert-text.ts b/frontend/src/ts/input/handlers/insert-text.ts index bae539777552..335c2da75654 100644 --- a/frontend/src/ts/input/handlers/insert-text.ts +++ b/frontend/src/ts/input/handlers/insert-text.ts @@ -180,8 +180,8 @@ export async function onInsertText(options: OnInsertTextParams): Promise { isFunboxActiveWithProperty("nospace") && (testInput + data).length === TestWords.words.getCurrentText().length; const shouldGoToNextWord = - (((charIsSpace || charIsNewline) && !shouldInsertSpace) || noSpaceForce) && - !removeLastChar; + !removeLastChar && + (((charIsSpace || charIsNewline) && !shouldInsertSpace) || noSpaceForce); // update test input state if (!charIsSpace || shouldInsertSpace) {