From e27c95450e85ba647a0e3a856258f767a06870cb Mon Sep 17 00:00:00 2001 From: Krystian Sienkiewicz Date: Tue, 8 Sep 2026 13:54:41 +0200 Subject: [PATCH] fix: stale head indent on selection change to a trailing newline --- ios/enrichedInputTextView/EnrichedInputTextView.mm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ios/enrichedInputTextView/EnrichedInputTextView.mm b/ios/enrichedInputTextView/EnrichedInputTextView.mm index 4e8dd50ba..65ada0d35 100644 --- a/ios/enrichedInputTextView/EnrichedInputTextView.mm +++ b/ios/enrichedInputTextView/EnrichedInputTextView.mm @@ -56,6 +56,15 @@ - (CGRect)caretRectForPosition:(UITextPosition *)position { rect.origin.x = (containerWidth - rect.size.width) / 2.0; } else if (alignment == NSTextAlignmentRight) { rect.origin.x = containerWidth - rect.size.width; + } else { + // when we change selection to the last empty line in the editor, + // where we literally have no character there, UIKit seems to need to know + // the line's expected geometry (indent) and it derives typing attributes + // from the previous character (previous line). Happens even though we + // explicitly didn't want that in + // manageTypingAttributesWithOnlySelection:YES, so we can't trust typing + // attributes' pStyle here, manually setting the caret's position + rect.origin.x = 0; } return rect;