Skip to content

Commit e27c954

Browse files
committed
fix: stale head indent on selection change to a trailing newline
1 parent 5a733d4 commit e27c954

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

ios/enrichedInputTextView/EnrichedInputTextView.mm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ - (CGRect)caretRectForPosition:(UITextPosition *)position {
5656
rect.origin.x = (containerWidth - rect.size.width) / 2.0;
5757
} else if (alignment == NSTextAlignmentRight) {
5858
rect.origin.x = containerWidth - rect.size.width;
59+
} else {
60+
// when we change selection to the last empty line in the editor,
61+
// where we literally have no character there, UIKit seems to need to know
62+
// the line's expected geometry (indent) and it derives typing attributes
63+
// from the previous character (previous line). Happens even though we
64+
// explicitly didn't want that in
65+
// manageTypingAttributesWithOnlySelection:YES, so we can't trust typing
66+
// attributes' pStyle here, manually setting the caret's position
67+
rect.origin.x = 0;
5968
}
6069

6170
return rect;

0 commit comments

Comments
 (0)