refactor: zen mode empty word appending

this also fixes some jumpiness when show all lines is enabled
This commit is contained in:
Miodec 2025-03-31 14:46:09 +02:00
parent f7666ab8e3
commit c55901efef
2 changed files with 13 additions and 20 deletions

View file

@ -190,11 +190,6 @@ async function handleSpace(): Promise<void> {
return;
}
if (Config.mode === "zen") {
$("#words .word.active").removeClass("active");
$("#words").append("<div class='word active'></div>");
}
const currentWord: string = TestWords.words.getCurrent();
for (const fb of getActiveFunboxesWithFunction("handleSpace")) {
@ -321,21 +316,14 @@ async function handleSpace(): Promise<void> {
) {
TimerProgress.update();
}
if (
Config.mode === "time" ||
Config.mode === "words" ||
Config.mode === "custom" ||
Config.mode === "quote"
) {
if (isLastWord) {
awaitingNextWord = true;
Loader.show();
await TestLogic.addWord();
Loader.hide();
awaitingNextWord = false;
} else {
void TestLogic.addWord();
}
if (isLastWord) {
awaitingNextWord = true;
Loader.show();
await TestLogic.addWord();
Loader.hide();
awaitingNextWord = false;
} else {
void TestLogic.addWord();
}
TestUI.updateActiveElement();
void Caret.updatePosition();

View file

@ -550,6 +550,11 @@ export function areAllTestWordsGenerated(): boolean {
//add word during the test
export async function addWord(): Promise<void> {
if (Config.mode === "zen") {
TestUI.appendEmptyWordElement();
return;
}
let bound = 100; // how many extra words to aim for AFTER the current word
const funboxToPush = getActiveFunboxes()
.find((f) => f.properties?.find((fp) => fp.startsWith("toPush")))