From 7db6c080f5992df76b10930908c2373634cd1911 Mon Sep 17 00:00:00 2001 From: Christoph Purrer Date: Mon, 25 Jul 2022 17:17:11 -0700 Subject: [PATCH] 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 --- Libraries/Text/Text/RCTTextView.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/Text/Text/RCTTextView.m b/Libraries/Text/Text/RCTTextView.m index 6726e12deab..de294585f2e 100644 --- a/Libraries/Text/Text/RCTTextView.m +++ b/Libraries/Text/Text/RCTTextView.m @@ -38,9 +38,9 @@ - (NSString *)description { NSString *superDescription = super.description; - NSRange semicolonRange = [superDescription rangeOfString:@";"]; - NSString *replacement = [NSString stringWithFormat:@"; reactTag: %@; text: %@", self.reactTag, _textStorage.string]; - return [superDescription stringByReplacingCharactersInRange:semicolonRange withString:replacement]; + NSRange replacementRange = [superDescription rangeOfString:@">"]; + NSString *replacement = [NSString stringWithFormat:@"; reactTag: %@; text: %@>", self.reactTag, _textStorage.string]; + return [superDescription stringByReplacingCharactersInRange:replacementRange withString:replacement]; } - (void)setSelectable:(BOOL)selectable @@ -113,7 +113,7 @@ // CATextLayer disables font smoothing by default now on macOS; we follow suit. CGContextSetShouldSmoothFonts(context, NO); #endif - + NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer]; [layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:_contentFrame.origin]; [layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:_contentFrame.origin]; @@ -157,7 +157,7 @@ [_highlightLayer removeFromSuperlayer]; _highlightLayer = nil; } - + #if TARGET_OS_MACCATALYST CGContextRestoreGState(context); #endif