Skip to content

Commit c55901e

Browse files
committed
refactor: zen mode empty word appending
this also fixes some jumpiness when show all lines is enabled
1 parent f7666ab commit c55901e

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

frontend/src/ts/controllers/input-controller.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,6 @@ async function handleSpace(): Promise<void> {
190190
return;
191191
}
192192

193-
if (Config.mode === "zen") {
194-
$("#words .word.active").removeClass("active");
195-
$("#words").append("<div class='word active'></div>");
196-
}
197-
198193
const currentWord: string = TestWords.words.getCurrent();
199194

200195
for (const fb of getActiveFunboxesWithFunction("handleSpace")) {
@@ -321,21 +316,14 @@ async function handleSpace(): Promise<void> {
321316
) {
322317
TimerProgress.update();
323318
}
324-
if (
325-
Config.mode === "time" ||
326-
Config.mode === "words" ||
327-
Config.mode === "custom" ||
328-
Config.mode === "quote"
329-
) {
330-
if (isLastWord) {
331-
awaitingNextWord = true;
332-
Loader.show();
333-
await TestLogic.addWord();
334-
Loader.hide();
335-
awaitingNextWord = false;
336-
} else {
337-
void TestLogic.addWord();
338-
}
319+
if (isLastWord) {
320+
awaitingNextWord = true;
321+
Loader.show();
322+
await TestLogic.addWord();
323+
Loader.hide();
324+
awaitingNextWord = false;
325+
} else {
326+
void TestLogic.addWord();
339327
}
340328
TestUI.updateActiveElement();
341329
void Caret.updatePosition();

frontend/src/ts/test/test-logic.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,11 @@ export function areAllTestWordsGenerated(): boolean {
550550

551551
//add word during the test
552552
export async function addWord(): Promise<void> {
553+
if (Config.mode === "zen") {
554+
TestUI.appendEmptyWordElement();
555+
return;
556+
}
557+
553558
let bound = 100; // how many extra words to aim for AFTER the current word
554559
const funboxToPush = getActiveFunboxes()
555560
.find((f) => f.properties?.find((fp) => fp.startsWith("toPush")))

0 commit comments

Comments
 (0)