fix(ios): reset typing attributes before importing markdown - #646
Open
hsource wants to merge 1 commit into
Open
Conversation
UITextView applies typingAttributes to all text assigned via .text. When setValue runs while the cursor was in a list item, stale list paragraph indent leaked onto non-list lines. Reset base attributes before ENRMSetPlainText so importMarkdown only applies block styling from the parsed markdown. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
What/Why?
When
setValuereloads markdown viaimportMarkdown, iOS assigns plain text usingtextView.text = .... UITextView stamps the currenttypingAttributesonto all of that text — including any list paragraphheadIndentleft over from where the cursor was before blur.If the user blurs while focused in a nested list item, non-list paragraphs incorrectly pick up that list indent after
setValue, even though the parsed markdown and block store are correct.Reset base typing attributes before
ENRMSetPlainTextso import only applies block styling from the parsed markdown (viaapplyFormatting), not stale composer state from the previous cursor position.Testing
EnrichedMarkdownTextInputwith mixed content: a normal paragraph, a nested list, and another normal paragraph.setValuewith the current markdown (e.g. on blur to refresh link formatting).Tested on iOS
PR Checklist