From b229dd417f0ab2faa936404de2534984802279c3 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 27 Jun 2024 18:59:11 -0700 Subject: [PATCH] Apply patch from E/App --- src/web/cursorUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/cursorUtils.ts b/src/web/cursorUtils.ts index 1cda6599..ba5c3c3e 100644 --- a/src/web/cursorUtils.ts +++ b/src/web/cursorUtils.ts @@ -66,7 +66,7 @@ function setCursorPosition(target: HTMLElement, start: number, end: number | nul // 3. Caret at the end of whole input, when pressing enter // 4. All other placements if (prevChar === '\n' && prevTextLength !== undefined && prevTextLength < textCharacters.length) { - if (nextChar !== '\n') { + if (nextChar && nextChar !== '\n' && i !== n - 1) { range.setStart(textNodes[i + 1] as Node, 0); } else if (i !== textNodes.length - 1) { range.setStart(textNodes[i] as Node, 1);