Skip to content

Commit 7db6c08

Browse files
Fix exception thrown by [RCTTextView description] on macOS
Summary: This method assumes a semicolon existed before the closing bracket (`>`), but only does on iOS. This instead puts the content before the closing bracket, which is always there on both platforms. Changelog: [macOS][Fixed] - Fix exception thrown by [RCTTextView description] on macOS Reviewed By: sammy-SC Differential Revision: D38074642 fbshipit-source-id: f46d15c2bf2d966d1c1430568f083e4d501d4b40
1 parent e7a8d21 commit 7db6c08

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Libraries/Text/Text/RCTTextView.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ - (instancetype)initWithFrame:(CGRect)frame
3838
- (NSString *)description
3939
{
4040
NSString *superDescription = super.description;
41-
NSRange semicolonRange = [superDescription rangeOfString:@";"];
42-
NSString *replacement = [NSString stringWithFormat:@"; reactTag: %@; text: %@", self.reactTag, _textStorage.string];
43-
return [superDescription stringByReplacingCharactersInRange:semicolonRange withString:replacement];
41+
NSRange replacementRange = [superDescription rangeOfString:@">"];
42+
NSString *replacement = [NSString stringWithFormat:@"; reactTag: %@; text: %@>", self.reactTag, _textStorage.string];
43+
return [superDescription stringByReplacingCharactersInRange:replacementRange withString:replacement];
4444
}
4545

4646
- (void)setSelectable:(BOOL)selectable
@@ -113,7 +113,7 @@ - (void)drawRect:(CGRect)rect
113113
// CATextLayer disables font smoothing by default now on macOS; we follow suit.
114114
CGContextSetShouldSmoothFonts(context, NO);
115115
#endif
116-
116+
117117
NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
118118
[layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:_contentFrame.origin];
119119
[layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:_contentFrame.origin];
@@ -157,7 +157,7 @@ - (void)drawRect:(CGRect)rect
157157
[_highlightLayer removeFromSuperlayer];
158158
_highlightLayer = nil;
159159
}
160-
160+
161161
#if TARGET_OS_MACCATALYST
162162
CGContextRestoreGState(context);
163163
#endif

0 commit comments

Comments
 (0)