Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new fallback branch can regress RTL behavior for NSTextAlignmentNatural/Justified by forcing the caret to x=0 instead of the leading edge in right-to-left layout direction.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adjusts iOS caret positioning for empty paragraphs (notably the trailing newline “empty last line”) to prevent UIKit from inheriting stale paragraph indentation (e.g., from lists/blockquote) when the selection changes, which can incorrectly shift the caret.
Changes:
- Updates
caretRectForPosition:to explicitly set the caret’s horizontal position for empty paragraphs when alignment isn’t center/right. - Adds inline rationale explaining why typing attributes/paragraph style can’t be relied on for caret geometry in this scenario.
File summaries
| File | Description |
|---|---|
| ios/enrichedInputTextView/EnrichedInputTextView.mm | Forces caret x-position to avoid stale indent affecting caret placement on empty trailing lines. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
hejsztynx
marked this pull request as ready for review
September 8, 2026 12:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When we had the editor's content ending with a newline, meant we had literally no character in that line at all. This caused UIKit to derive typing attributes from the previous character (previous line) on selection change. This happened even though we explicitly reset typing attributes in
manageTypingAttributesWithOnlySelection, whenonlySelectionChangedis true.E.g. we change selection to that empty newline, and typingAttributes get derived from an unordered list that is above it. This caused the list indent to be applied on an unstyled line, incorrectly moving the caret. This issue could be reproduced with any style that uses an indent - list styles, blockquote.
Fixed it by explicitly setting the caret's position on empty lines to
0. Previously we were falling back to any values that were in the typing attributes state.I've run all e2e tests, all passed.
Test Plan
Reproduce the steps shown in the attached videos. Verify it's working correctly.
Screenshots / Videos
Before:
Screen.Recording.2026-09-08.at.14.36.55.mov
This also happened with other indent-modifying styles, e.g.
After:
Screen.Recording.2026-09-08.at.13.52.29.mov
Compatibility
Checklist