From 4befe17cab81805ddfcdb6e4e8956566b0d609aa Mon Sep 17 00:00:00 2001 From: daboe01 Date: Wed, 28 Sep 2016 17:24:39 +0200 Subject: [PATCH] fixed: target index in selection dragging was sometimes wrong --- AppKit/CPTextView/CPTextView.j | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 16ec3740c..8bd00a039 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -942,11 +942,11 @@ var kDelegateRespondsTo_textShouldBeginEditing _movingSelection = CPMakeRange(_startTrackingLocation, 0); var dragPlaceholder = [CPTextField new], originPoint = [_layoutManager locationForGlyphAtIndex:[self selectedRange].location]; - - originPoint.y -= [_layoutManager _descentAtLocation:_selectionRange.location]; + + originPoint.y += [_layoutManager _characterOffsetAtLocation:_selectionRange.location] + _textContainerOrigin.y - 1; originPoint.x += _textContainerOrigin.x; - originPoint.y += _textContainerOrigin.y; + dragPlaceholder._DOMElement.style.opacity = '0.6'; [dragPlaceholder setStringValue:[[self stringValue] substringWithRange:_selectionRange]]; [dragPlaceholder sizeToFit]; @@ -2025,6 +2025,9 @@ var kDelegateRespondsTo_textShouldBeginEditing return; } + if (_movingSelection.location > CPMaxRange(_selectionRange)) + _movingSelection.location -= _selectionRange.length; + [self _deleteForRange:_selectionRange]; [self setSelectedRange:_movingSelection];