Skip to content

Commit 6a42e23

Browse files
committed
优化输入服务:1. 修改光标位置检查逻辑,确保在变量末尾时正确返回变量起始位置;2. 保持对数字内部检查的逻辑不变。
1 parent a9c80d6 commit 6a42e23

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/services/inputService.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,13 @@ export class InputService {
356356
currentPos: number,
357357
variables: Variable[]
358358
): number {
359-
// 首先检查是否在数字内部
359+
// 首先检查当前位置是否刚好在变量末尾
360+
const variableAtCursorEnd = this.checkCursorInVariable(text, currentPos - 1, variables);
361+
if (variableAtCursorEnd) {
362+
return variableAtCursorEnd.start;
363+
}
364+
365+
// 检查是否在数字内部
360366
const currentNumber = this.isInNumber(text, currentPos);
361367
if (currentNumber && currentPos > currentNumber.start) {
362368
return currentNumber.start;

0 commit comments

Comments
 (0)