Skip to content

Commit 53aaba2

Browse files
committed
yes honey
1 parent 79aed3d commit 53aaba2

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

frontend/src/ts/input/handlers/insert-text.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { goToNextWord } from "../helpers/word-navigation";
3333
import { onBeforeInsertText } from "./before-insert-text";
3434
import { shouldGoToNextWord, isCharCorrect } from "../helpers/validation";
3535
import { getCurrentInput, logTestEvent } from "../../test/events/data";
36+
import { isCommitCharacter } from "../helpers/util";
3637

3738
const charOverrides = new Map<string, string>([
3839
["…", "..."],
@@ -142,6 +143,11 @@ export async function onInsertText(options: OnInsertTextParams): Promise<void> {
142143
const wordIndex = TestState.activeWordIndex;
143144
const correctShiftUsed =
144145
Config.oppositeShiftMode === "off" ? null : isCorrectShiftUsed();
146+
const isCommit = isCommitCharacter({
147+
data,
148+
inputValue: testInput,
149+
targetWord: currentWord,
150+
});
145151

146152
// is char correct
147153
const correct = isCharCorrect({
@@ -174,6 +180,7 @@ export async function onInsertText(options: OnInsertTextParams): Promise<void> {
174180
data,
175181
inputValue: testInput,
176182
targetWord: currentWord,
183+
isCommitCharacter: isCommit,
177184
});
178185

179186
if (correctShiftUsed === false) {
@@ -274,6 +281,7 @@ export async function onInsertText(options: OnInsertTextParams): Promise<void> {
274281
testInput: testInput,
275282
targetWord: currentWord,
276283
correct,
284+
isCommitCharacter: isCommit,
277285
})
278286
) {
279287
TestLogic.fail("difficulty");

frontend/src/ts/input/helpers/fail-or-finish.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Config } from "../../config/store";
22
import { whorf } from "../../utils/misc";
3-
import { isCommitCharacter } from "./util";
43

54
/**
65
* Check if the test should fail due to minimum burst settings
@@ -46,20 +45,17 @@ export function checkIfFailedDueToDifficulty(options: {
4645
testInput: string;
4746
targetWord: string;
4847
correct: boolean;
48+
isCommitCharacter: boolean;
4949
}): boolean {
50-
const { data, testInput, correct, targetWord } = options;
50+
const { data, testInput, correct, targetWord, isCommitCharacter } = options;
5151
// Using space or newline instead of shouldInsertSpace or increasedWordIndex
5252
// because we want expert mode to fail no matter if confidence or stop on error is on
5353

5454
if (Config.mode === "zen") return false;
5555

5656
const shouldFailDueToExpert =
5757
Config.difficulty === "expert" &&
58-
isCommitCharacter({
59-
data,
60-
inputValue: testInput,
61-
targetWord,
62-
}) &&
58+
isCommitCharacter &&
6359
testInput + data !== targetWord;
6460

6561
const shouldFailDueToMaster = Config.difficulty === "master" && !correct;

frontend/src/ts/input/helpers/validation.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Config } from "../../config/store";
2-
import { isCommitCharacter } from "./util";
32

43
/**
54
* Check if the input data is correct
@@ -40,12 +39,11 @@ export function shouldGoToNextWord(options: {
4039
data: string;
4140
inputValue: string;
4241
targetWord: string;
42+
isCommitCharacter: boolean;
4343
}): boolean {
44-
const { inputValue, targetWord, data } = options;
44+
const { inputValue, targetWord, data, isCommitCharacter } = options;
4545

46-
const isCommit = isCommitCharacter(options);
47-
48-
if (!isCommit) return false;
46+
if (!isCommitCharacter) return false;
4947

5048
if (Config.mode === "zen") return true;
5149

0 commit comments

Comments
 (0)