@@ -1629,6 +1629,7 @@ - (CGRect)firstRectForRange:(UITextRange*)range {
1629
1629
1630
1630
- (CGRect )caretRectForPosition : (UITextPosition*)position {
1631
1631
NSInteger index = ((FlutterTextPosition*)position).index ;
1632
+ // Get the bounds of the characters before and after the requested caret position.
1632
1633
NSArray <UITextSelectionRect*>* rects =
1633
1634
[self selectionRectsForRange: [FlutterTextRange
1634
1635
rangeWithNSRange: fml: :RangeForCharactersInRange (
@@ -1638,10 +1639,17 @@ - (CGRect)caretRectForPosition:(UITextPosition*)position {
1638
1639
return CGRectZero ;
1639
1640
}
1640
1641
if (index == 0 ) {
1641
- return CGRectMake (rects[0 ].rect .origin .x , rects[0 ].rect .origin .y , 0 , rects[0 ].rect .size .height );
1642
+ // There is no character before the caret, so this will be the bounds of the character after the
1643
+ // caret position.
1644
+ CGRect characterAfterCaret = rects[0 ].rect ;
1645
+ // Return a zero-width rectangle along the left edge of the character after the caret position.
1646
+ return CGRectMake (characterAfterCaret.origin .x , characterAfterCaret.origin .y , 0 ,
1647
+ characterAfterCaret.size .height );
1642
1648
}
1643
- return CGRectMake (rects[0 ].rect.origin.x + rects[0 ].rect.size.width, rects[0 ].rect.origin.y, 0 ,
1644
- rects[0 ].rect.size.height);
1649
+ CGRect characterBeforeCaret = rects[0 ].rect;
1650
+ // Return a zero-width rectangle along the right edge of the character before the caret position.
1651
+ return CGRectMake (characterBeforeCaret.origin.x + characterBeforeCaret.size.width,
1652
+ characterBeforeCaret.origin.y, 0 , characterBeforeCaret.size.height);
1645
1653
}
1646
1654
1647
1655
- (UITextPosition*)closestPositionToPoint: (CGPoint )point {
@@ -1761,7 +1769,7 @@ - (void)beginFloatingCursorAtPoint:(CGPoint)point {
1761
1769
[self .textInputDelegate flutterTextInputView: self
1762
1770
updateFloatingCursor: FlutterFloatingCursorDragStateStart
1763
1771
withClient: _textInputClient
1764
- withPosition: @{@" X" : @( 0 ) , @" Y" : @( 0 ) }];
1772
+ withPosition: @{@" X" : @0 , @" Y" : @0 }];
1765
1773
}
1766
1774
1767
1775
- (void )updateFloatingCursorAtPoint: (CGPoint )point {
@@ -1780,7 +1788,7 @@ - (void)endFloatingCursor {
1780
1788
[self .textInputDelegate flutterTextInputView: self
1781
1789
updateFloatingCursor: FlutterFloatingCursorDragStateEnd
1782
1790
withClient: _textInputClient
1783
- withPosition: @{@" X" : @( 0 ) , @" Y" : @( 0 ) }];
1791
+ withPosition: @{@" X" : @0 , @" Y" : @0 }];
1784
1792
}
1785
1793
1786
1794
#pragma mark - UIKeyInput Overrides
0 commit comments