diff --git a/AppKit/CPTextView/CPLayoutManager.j b/AppKit/CPTextView/CPLayoutManager.j index b1d22ea80..4bd345dc4 100644 --- a/AppKit/CPTextView/CPLayoutManager.j +++ b/AppKit/CPTextView/CPLayoutManager.j @@ -965,16 +965,11 @@ _oncontextmenuhandler = function () { return false; }; if (frame) { var correctedRect = CGRectCreateCopy(frame); - correctedRect.size.height -= frame._descent; - correctedRect.origin.y -= frame._descent; if (!rect) rect = CGRectCreateCopy(correctedRect); else rect = CGRectUnion(rect, correctedRect); - - if (_isNewlineCharacter([[_textStorage string] characterAtIndex:MAX(0, CPMaxRange(selectedCharRange) - 1)])) - rect.size.width = containerSize.width - rect.origin.x; } } } @@ -1348,7 +1343,10 @@ var _objectsInRange = function(aList, aRange) { _glyphsFrames[i] = CGRectMake(origin.x, origin.y, someAdvancements[i].width, height); _glyphsFrames[i]._descent = someAdvancements[i].descent; - _glyphsOffsets[i] = height - someAdvancements[i].height; + + // Align the run's baseline with the common line baseline (_location.y) + _glyphsOffsets[i] = _location.y - someAdvancements[i].height; + origin.x += someAdvancements[i].width; } } diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 0398d8f46..b4260e217 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -2337,17 +2337,15 @@ Sets the selection to a range of characters in response to user action. var loc = (_selectionRange.location == numberOfGlyphs) ? _selectionRange.location - 1 : _selectionRange.location, caretOffset = [_layoutManager _characterOffsetAtLocation:loc], - oldYPosition = CGRectGetMaxY(caretRect), - caretDescend = [_layoutManager _descentAtLocation:loc]; + font = [_textStorage attribute:CPFontAttributeName atIndex:loc effectiveRange:nil] || [self font]; if (caretOffset > 0) { caretRect.origin.y += caretOffset; - caretRect.size.height = oldYPosition - caretRect.origin.y; } - if (caretDescend < 0) - caretRect.size.height -= caretDescend; + // Set the caret height to match the size of the active font + caretRect.size.height = [font size]; if (_selectionRange.location == numberOfGlyphs) caretRect.origin.x += caretRect.size.width; @@ -2356,7 +2354,7 @@ Sets the selection to a range of characters in response to user action. caretRect.origin.y += _textContainerOrigin.y; caretRect.size.width = MAX(1.0, caretRect.size.width); - caretRect.size.height = MAX(1.0, caretRect.size.height); + caretRect.size.height = MAX(1.0, caretRect.size.height) + 2; return caretRect; }