From 87edda5972a902ea95d271b2c365b0627502945e Mon Sep 17 00:00:00 2001 From: daboe01 Date: Wed, 30 Dec 2015 21:16:02 +0100 Subject: [PATCH] more cursor up fixes --- AppKit/CPTextView/CPTextView.j | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 5da7c3482..fa69da99b 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -1011,16 +1011,20 @@ var kDelegateRespondsTo_textShouldBeginEditing if (![self isSelectable]) return; - var dindex = [self selectedRange].location, - rectSource = [_layoutManager boundingRectForGlyphRange:CPMakeRange(dindex, 1) inTextContainer:_textContainer]; - - if (rectSource.origin.x > 0) - dindex = [_layoutManager glyphIndexForPoint:CGPointMake(0, rectSource.origin.y + 1) inTextContainer:_textContainer fractionOfDistanceThroughGlyph:nil]; + var dindex = [self selectedRange].location; if (dindex < 1) return; - rectSource = [_layoutManager boundingRectForGlyphRange:CPMakeRange(dindex - 1, 1) inTextContainer:_textContainer]; // the line above + var rectSource = [_layoutManager boundingRectForGlyphRange:CPMakeRange(dindex, 1) inTextContainer:_textContainer]; + + if (!(dindex === [_layoutManager numberOfCharacters] && _isNewlineCharacter([[_textStorage string] characterAtIndex:dindex - 1]))) + dindex = [_layoutManager glyphIndexForPoint:CGPointMake(0, rectSource.origin.y + 1) inTextContainer:_textContainer fractionOfDistanceThroughGlyph:nil]; + + if (dindex < 1) + return; + + rectSource = [_layoutManager boundingRectForGlyphRange:CPMakeRange(dindex - 1, 1) inTextContainer:_textContainer]; dindex = [_layoutManager glyphIndexForPoint:CGPointMake(_stickyXLocation, rectSource.origin.y + 1) inTextContainer:_textContainer fractionOfDistanceThroughGlyph:nil]; var oldStickyLoc = _stickyXLocation;