From a1335850a3f0ce1b90a2bf13ad8532f0ccf06cff Mon Sep 17 00:00:00 2001 From: zhoujingfu <43539608+zhoujingfu@users.noreply.github.com> Date: Tue, 13 Jun 2023 22:57:33 +0800 Subject: [PATCH] improve: cursor selection at the beginning of a line #202 Co-authored-by: Hufe921 --- src/editor/core/position/Position.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/editor/core/position/Position.ts b/src/editor/core/position/Position.ts index df2191d..e284c5b 100644 --- a/src/editor/core/position/Position.ts +++ b/src/editor/core/position/Position.ts @@ -332,7 +332,10 @@ export class Position { // 是否在头部 if (isHead) { const headIndex = positionList.findIndex(p => p.pageNo === positionNo && p.rowNo === lastLetterList[j].rowNo) - curPositionIndex = ~headIndex ? headIndex - 1 : index + // 头部元素为空元素时无需选中 + curPositionIndex = ~headIndex + ? positionList[headIndex].value === ZERO ? headIndex : headIndex - 1 + : index } else { curPositionIndex = index }