TextKitEditor icon indicating copy to clipboard operation
TextKitEditor copied to clipboard

Endless recursive call

Open Lessica opened this issue 8 years ago • 0 comments

In TKELayoutManager.m:

// The additional indent is the distance from the first to the last character
leftInset += [self locationForGlyphAtIndex:firstTextGlyphIndex].x - [self locationForGlyphAtIndex:firstGlyphIndex].x;

But, -[NSLayoutManager locationForGlyphAtIndex:] may call -[NSTextContainer lineFragmentRectForProposedRect:atIndex:writingDirection:remainingRect:] by default.

In TKETextContainer.m:

UIEdgeInsets insets = [(TKELayoutManager *)self.layoutManager insetsForLineStartingAtCharacterIndex: characterIndex];
rect.size.width -= insets.left + insets.right;
return rect;

Which causes endless recursive call and crashes the application.

Lessica avatar Dec 15 '17 06:12 Lessica