mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Same cursor offset within lines for all TextAffinities to prevent cursor shifting/moving. (#23485)
This commit is contained in:
parent
340c158f32
commit
6827d0920b
@ -1 +1 @@
|
||||
afef1dc571f94a41751917d3946defba782335f7
|
||||
055a75c5a63bf2b2c5142b38b88829593908fd10
|
||||
|
||||
@ -421,7 +421,7 @@ class TextPainter {
|
||||
return null;
|
||||
final TextBox box = boxes[0];
|
||||
final double caretEnd = box.end;
|
||||
final double dx = box.direction == TextDirection.rtl ? caretEnd : caretEnd - caretPrototype.width;
|
||||
final double dx = box.direction == TextDirection.rtl ? caretEnd - caretPrototype.width : caretEnd;
|
||||
return Offset(dx, box.top);
|
||||
}
|
||||
|
||||
|
||||
@ -741,6 +741,11 @@ void main() {
|
||||
final Offset firstPos = textOffsetToPosition(tester, testValue.indexOf('First'));
|
||||
final Offset secondPos = textOffsetToPosition(tester, testValue.indexOf('Second'));
|
||||
final Offset thirdPos = textOffsetToPosition(tester, testValue.indexOf('Third'));
|
||||
final Offset middleStringPos = textOffsetToPosition(tester, testValue.indexOf('irst'));
|
||||
expect(firstPos.dx, 0);
|
||||
expect(secondPos.dx, 0);
|
||||
expect(thirdPos.dx, 0);
|
||||
expect(middleStringPos.dx, 34);
|
||||
expect(firstPos.dx, secondPos.dx);
|
||||
expect(firstPos.dx, thirdPos.dx);
|
||||
expect(firstPos.dy, lessThan(secondPos.dy));
|
||||
@ -823,6 +828,8 @@ void main() {
|
||||
// Check that the last line of text is not displayed.
|
||||
final Offset firstPos = textOffsetToPosition(tester, kMoreThanFourLines.indexOf('First'));
|
||||
final Offset fourthPos = textOffsetToPosition(tester, kMoreThanFourLines.indexOf('Fourth'));
|
||||
expect(firstPos.dx, 0);
|
||||
expect(fourthPos.dx, 0);
|
||||
expect(firstPos.dx, fourthPos.dx);
|
||||
expect(firstPos.dy, lessThan(fourthPos.dy));
|
||||
expect(inputBox.hitTest(HitTestResult(), position: inputBox.globalToLocal(firstPos)), isTrue);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user