From 84888c25dd0ca477b38908a938ad60a7c0428a50 Mon Sep 17 00:00:00 2001 From: Brian Sung <6445410+seoulection@users.noreply.github.com> Date: Mon, 5 Jun 2023 03:13:30 -0700 Subject: [PATCH] remove last newlines if backspace ends up on newline (#4322) seoulection --- frontend/src/ts/controllers/input-controller.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index 981e4231d..74f15337a 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -137,6 +137,19 @@ function backspaceToPrevious(): void { Funbox.toggleScript(TestWords.words.getCurrent()); TestUI.updateWordElement(); + if (Config.mode === "zen") { + const els: HTMLElement[] = (document.querySelector("#words")?.children || + []) as HTMLElement[]; + + for (let i = els.length - 1; i >= 0; i--) { + if (els[i].classList.contains("newline")) { + els[i].remove(); + } else { + break; + } + } + } + Caret.updatePosition(); Replay.addReplayEvent("backWord"); }