remove last newlines if backspace ends up on newline (#4322) seoulection

This commit is contained in:
Brian Sung 2023-06-05 03:13:30 -07:00 committed by GitHub
parent 801d84fafe
commit 84888c25dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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");
}