Small fixes in cursor position calculation
This commit is contained in:
parent
558a1848a0
commit
478b82b1e1
1 changed files with 3 additions and 6 deletions
|
@ -92,16 +92,14 @@ export class TextField extends InputElement<string> {
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
val = field.value;
|
val = field.value;
|
||||||
let newCursorPos = endDistance;
|
let newCursorPos = val.length - endDistance;
|
||||||
while(newCursorPos >= 0 &&
|
while(newCursorPos >= 0 &&
|
||||||
// We count the number of _actual_ characters (non-space characters) on the right of the new value
|
// We count the number of _actual_ characters (non-space characters) on the right of the new value
|
||||||
// This count should become bigger then the end distance
|
// This count should become bigger then the end distance
|
||||||
val.substr(newCursorPos).replace(/ /g, '').length <= endDistance
|
val.substr(newCursorPos).replace(/ /g, '').length < endDistance
|
||||||
){
|
){
|
||||||
newCursorPos --;
|
newCursorPos --;
|
||||||
}
|
}
|
||||||
newCursorPos++;
|
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
self.SetCursorPosition(newCursorPos);
|
self.SetCursorPosition(newCursorPos);
|
||||||
};
|
};
|
||||||
|
@ -147,4 +145,3 @@ export class TextField extends InputElement<string> {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue