fix: move cursor boundary error with up and down keys #556

pr675
zhaopeng 2 years ago committed by GitHub
parent 73e47f56b5
commit d58b28c1db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -14,12 +14,13 @@ interface IGetNextPositionIndexPayload {
// 根据当前位置索引查找上下行最接近的索引位置
function getNextPositionIndex(payload: IGetNextPositionIndexPayload) {
const { positionList, index, isUp, rowNo, cursorX } = payload
let nextIndex = 0
let nextIndex = -1
// 查找下一行位置列表
const probablePosition: IElementPosition[] = []
if (isUp) {
let p = index - 1
while (p > 0) {
// 等于0的时候上一行是第一行
while (p >= 0) {
const position = positionList[p]
p--
if (position.rowNo === rowNo) continue
@ -215,7 +216,7 @@ export function updown(evt: KeyboardEvent, host: CanvasEvent) {
isUp,
cursorX: curRightX
})
if (!nextIndex) return
if (nextIndex < 0) return
// shift则缩放选区
anchorStartIndex = nextIndex
anchorEndIndex = nextIndex

Loading…
Cancel
Save