Skip to content

Commit

Permalink
Fix end offset issue when highlightRange > visibleRange
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyin1986 committed Jan 8, 2020
1 parent d98bc83 commit b144f1f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion YYText/YYLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
YYTextAction tapAction = _highlight.tapAction ? _highlight.tapAction : _highlightTapAction;
if (tapAction) {
YYTextPosition *start = [YYTextPosition positionWithOffset:_highlightRange.location];
YYTextPosition *end = [YYTextPosition positionWithOffset:_highlightRange.location + _highlightRange.length affinity:YYTextAffinityBackward];
NSInteger endOffset = MIN(_innerLayout.visibleRange.length, _highlightRange.location + _highlightRange.length);
YYTextPosition *end = [YYTextPosition positionWithOffset:endOffset affinity:YYTextAffinityBackward];
YYTextRange *range = [YYTextRange rangeWithStart:start end:end];
CGRect rect = [self._innerLayout rectForRange:range];
rect = [self _convertRectFromLayout:rect];
Expand Down

0 comments on commit b144f1f

Please sign in to comment.