From ceb3b8eec65725994a6bf5ea4415a319b9c68fdd Mon Sep 17 00:00:00 2001 From: IvanIhnatsiuk Date: Mon, 15 Dec 2025 00:00:17 +0100 Subject: [PATCH 1/4] fix: redraw elements only in visible area --- ios/utils/LayoutManagerExtension.mm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ios/utils/LayoutManagerExtension.mm b/ios/utils/LayoutManagerExtension.mm index 050e26b0e..a760b7698 100644 --- a/ios/utils/LayoutManagerExtension.mm +++ b/ios/utils/LayoutManagerExtension.mm @@ -50,11 +50,12 @@ - (void)my_drawBackgroundForGlyphRange:(NSRange)glyphRange return; } - NSRange inputRange = NSMakeRange(0, typedInput->textView.textStorage.length); + NSRange visibleCharRange = [self characterRangeForGlyphRange:glyphRange + actualGlyphRange:NULL]; - [self drawBlockQuotes:typedInput origin:origin inputRange:inputRange]; - [self drawLists:typedInput origin:origin inputRange:inputRange]; - [self drawCodeBlocks:typedInput origin:origin inputRange:inputRange]; + [self drawBlockQuotes:typedInput origin:origin inputRange:visibleCharRange]; + [self drawLists:typedInput origin:origin inputRange:visibleCharRange]; + [self drawCodeBlocks:typedInput origin:origin inputRange:visibleCharRange]; } - (void)drawCodeBlocks:(EnrichedTextInputView *)typedInput From 2f0f44dfcc8f69cfba2adabf3929e8f98dfef1fe Mon Sep 17 00:00:00 2001 From: IvanIhnatsiuk Date: Mon, 15 Dec 2025 00:31:11 +0100 Subject: [PATCH 2/4] fix: rename args --- ios/utils/LayoutManagerExtension.mm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ios/utils/LayoutManagerExtension.mm b/ios/utils/LayoutManagerExtension.mm index a760b7698..4ec15b929 100644 --- a/ios/utils/LayoutManagerExtension.mm +++ b/ios/utils/LayoutManagerExtension.mm @@ -53,14 +53,18 @@ - (void)my_drawBackgroundForGlyphRange:(NSRange)glyphRange NSRange visibleCharRange = [self characterRangeForGlyphRange:glyphRange actualGlyphRange:NULL]; - [self drawBlockQuotes:typedInput origin:origin inputRange:visibleCharRange]; - [self drawLists:typedInput origin:origin inputRange:visibleCharRange]; - [self drawCodeBlocks:typedInput origin:origin inputRange:visibleCharRange]; + [self drawBlockQuotes:typedInput + origin:origin + visibleCharRange:visibleCharRange]; + [self drawLists:typedInput origin:origin visibleCharRange:visibleCharRange]; + [self drawCodeBlocks:typedInput + origin:origin + visibleCharRange:visibleCharRange]; } - (void)drawCodeBlocks:(EnrichedTextInputView *)typedInput origin:(CGPoint)origin - inputRange:(NSRange)inputRange { + visibleCharRange:(NSRange)inputRange { CodeBlockStyle *codeBlockStyle = typedInput->stylesDict[@([CodeBlockStyle getStyleType])]; if (codeBlockStyle == nullptr) { @@ -199,7 +203,7 @@ - (void)drawCodeBlocks:(EnrichedTextInputView *)typedInput - (void)drawBlockQuotes:(EnrichedTextInputView *)typedInput origin:(CGPoint)origin - inputRange:(NSRange)inputRange { + visibleCharRange:(NSRange)inputRange { BlockQuoteStyle *bqStyle = typedInput->stylesDict[@([BlockQuoteStyle getStyleType])]; if (bqStyle == nullptr) { @@ -241,8 +245,8 @@ - (void)drawBlockQuotes:(EnrichedTextInputView *)typedInput } - (void)drawLists:(EnrichedTextInputView *)typedInput - origin:(CGPoint)origin - inputRange:(NSRange)inputRange { + origin:(CGPoint)origin + visibleCharRange:(NSRange)inputRange { UnorderedListStyle *ulStyle = typedInput->stylesDict[@([UnorderedListStyle getStyleType])]; OrderedListStyle *olStyle = From db1e365cedece0f55264b6ceeab153a15b6ebb20 Mon Sep 17 00:00:00 2001 From: IvanIhnatsiuk Date: Mon, 15 Dec 2025 02:02:47 +0100 Subject: [PATCH 3/4] fix: rename method args --- ios/utils/LayoutManagerExtension.mm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ios/utils/LayoutManagerExtension.mm b/ios/utils/LayoutManagerExtension.mm index 4ec15b929..0d8b9849d 100644 --- a/ios/utils/LayoutManagerExtension.mm +++ b/ios/utils/LayoutManagerExtension.mm @@ -64,7 +64,7 @@ - (void)my_drawBackgroundForGlyphRange:(NSRange)glyphRange - (void)drawCodeBlocks:(EnrichedTextInputView *)typedInput origin:(CGPoint)origin - visibleCharRange:(NSRange)inputRange { + visibleCharRange:(NSRange)visibleCharRange { CodeBlockStyle *codeBlockStyle = typedInput->stylesDict[@([CodeBlockStyle getStyleType])]; if (codeBlockStyle == nullptr) { @@ -72,7 +72,7 @@ - (void)drawCodeBlocks:(EnrichedTextInputView *)typedInput } NSArray *allCodeBlocks = - [codeBlockStyle findAllOccurences:inputRange]; + [codeBlockStyle findAllOccurences:visibleCharRange]; NSArray *mergedCodeBlocks = [self mergeContiguousStylePairs:allCodeBlocks]; UIColor *bgColor = [[typedInput->config codeBlockBgColor] @@ -203,7 +203,7 @@ - (void)drawCodeBlocks:(EnrichedTextInputView *)typedInput - (void)drawBlockQuotes:(EnrichedTextInputView *)typedInput origin:(CGPoint)origin - visibleCharRange:(NSRange)inputRange { + visibleCharRange:(NSRange)visibleCharRange { BlockQuoteStyle *bqStyle = typedInput->stylesDict[@([BlockQuoteStyle getStyleType])]; if (bqStyle == nullptr) { @@ -212,7 +212,7 @@ - (void)drawBlockQuotes:(EnrichedTextInputView *)typedInput // it isn't the most performant but we have to check for all the blockquotes // each time and redraw them - NSArray *allBlockquotes = [bqStyle findAllOccurences:inputRange]; + NSArray *allBlockquotes = [bqStyle findAllOccurences:visibleCharRange]; for (StylePair *pair in allBlockquotes) { NSRange paragraphRange = [typedInput->textView.textStorage.string @@ -246,7 +246,7 @@ - (void)drawBlockQuotes:(EnrichedTextInputView *)typedInput - (void)drawLists:(EnrichedTextInputView *)typedInput origin:(CGPoint)origin - visibleCharRange:(NSRange)inputRange { + visibleCharRange:(NSRange)visibleCharRange { UnorderedListStyle *ulStyle = typedInput->stylesDict[@([UnorderedListStyle getStyleType])]; OrderedListStyle *olStyle = @@ -257,8 +257,8 @@ - (void)drawLists:(EnrichedTextInputView *)typedInput // also not the most performant but we redraw all the lists NSMutableArray *allLists = [[NSMutableArray alloc] init]; - [allLists addObjectsFromArray:[ulStyle findAllOccurences:inputRange]]; - [allLists addObjectsFromArray:[olStyle findAllOccurences:inputRange]]; + [allLists addObjectsFromArray:[ulStyle findAllOccurences:visibleCharRange]]; + [allLists addObjectsFromArray:[olStyle findAllOccurences:visibleCharRange]]; for (StylePair *pair in allLists) { NSParagraphStyle *pStyle = (NSParagraphStyle *)pair.styleValue; From 546f8f9e7193013852c235b2f2f5b2abd19a8ad8 Mon Sep 17 00:00:00 2001 From: szydlovsky <9szydlowski9@gmail.com> Date: Wed, 17 Dec 2025 16:56:34 +0100 Subject: [PATCH 4/4] fix: remove comments about performance that aren't true anymore --- ios/utils/LayoutManagerExtension.mm | 3 --- 1 file changed, 3 deletions(-) diff --git a/ios/utils/LayoutManagerExtension.mm b/ios/utils/LayoutManagerExtension.mm index 0d8b9849d..2b011bddc 100644 --- a/ios/utils/LayoutManagerExtension.mm +++ b/ios/utils/LayoutManagerExtension.mm @@ -210,8 +210,6 @@ - (void)drawBlockQuotes:(EnrichedTextInputView *)typedInput return; } - // it isn't the most performant but we have to check for all the blockquotes - // each time and redraw them NSArray *allBlockquotes = [bqStyle findAllOccurences:visibleCharRange]; for (StylePair *pair in allBlockquotes) { @@ -255,7 +253,6 @@ - (void)drawLists:(EnrichedTextInputView *)typedInput return; } - // also not the most performant but we redraw all the lists NSMutableArray *allLists = [[NSMutableArray alloc] init]; [allLists addObjectsFromArray:[ulStyle findAllOccurences:visibleCharRange]]; [allLists addObjectsFromArray:[olStyle findAllOccurences:visibleCharRange]];