From 9c44a4d425197472656736b368ef3733964cabd2 Mon Sep 17 00:00:00 2001 From: satori Date: Wed, 15 Jan 2025 19:00:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=AD=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cursor.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cursor.js b/cursor.js index 84eaf5e..d251ae0 100644 --- a/cursor.js +++ b/cursor.js @@ -90,16 +90,14 @@ export class Cursor { if (key === "ArrowUp" && currentIndex > 0) { const prevSibling = siblings[currentIndex - 1] - const length = prevSibling.textContent.length - const index = length < this.insertIndex ? length : this.insertIndex + const index = Math.max(0, Math.min(prevSibling.textContent.length, this.insertIndex)) this.setTarget(prevSibling, index) // 光标在上一个兄弟元素的起始位置 return } if (key === "ArrowDown" && currentIndex >= 0 && currentIndex < siblings.length - 1) { const nextSibling = siblings[currentIndex + 1] - const length = nextSibling.textContent.length - const index = length < this.insertIndex ? length : this.insertIndex + const index = Math.max(0, Math.min(nextSibling.textContent.length, this.insertIndex)) this.setTarget(nextSibling, index) // 光标在下一个兄弟元素的起始位置 return }