fix: improve ZWS handling performance on iOS - #113
Merged
IvanIhnatsiuk merged 1 commit intoJul 2, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors iOS zero-width space (ZWS) handling in EnrichedTextInputView to reduce redundant style detection and improve text storage edit performance, and it tightens HTML parsing placeholder insertion rules for block elements.
Changes:
- Passes precomputed
zwsStylesthrough ZWS add/remove flows and adds an overload for style checks to avoid recomputing styles repeatedly. - Wraps ZWS insertion/removal mutations in
NSTextStoragebeginEditing/endEditingto reduce intermediate layout/notification churn. - Refines HTML empty-block placeholder insertion to focus on list-related tags.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ios/utils/Text/ZeroWidthSpaceUtils.mm | Refactors ZWS style detection to accept explicit styles and batches text storage edits for performance. |
| ios/parser/EnrichedHTMLToAttributedStringParser.mm | Narrows when ZWS placeholders are inserted for empty block elements during HTML traversal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
This pull request introduces several improvements to the handling of zero-width spaces (ZWS) in enriched text input, focusing on better style detection, more robust editing, and improved method signatures. The main changes include passing ZWS styles explicitly to relevant methods, ensuring batch editing of text storage for performance, and refining how placeholder logic is applied for block elements.
Zero-width space handling and style detection:
ZeroWidthSpaceUtilsmethods (removeSpacesIfNeededinInputandaddSpacesIfNeededinInput) to accept an explicitzwsStylesparameter, ensuring consistent style checks and reducing redundant style computation.findAnyZWSStylesInInput:range:zwsStyles:to check for ZWS styles within a range using a provided styles array, improving accuracy and efficiency when determining where ZWS handling is needed.Batch editing and performance:
beginEditing/endEditingcalls during ZWS removal and insertion, reducing the number of layout and notification events for better performance and stability.Code quality and correctness:
nullptrtonilfor Objective-C compatibility inhandleZeroWidthSpacesInInput.HTML parsing logic:
traverseNode:to only insert placeholders for list items and check list tags, not for all paragraph tags, making block placeholder insertion more precise.Test Plan
Provide clear steps so another contributor can reproduce the behavior or verify the feature works.
For example:
Screenshots / Videos
Include any visual proof that helps reviewers understand the change — UI updates, bug reproduction or the result of the fix.
Compatibility