                 effectiveRange.formUnion(glyphRange)
                 
             } else {
-                // clamp the bound with `numberOfGlyphs - 1`
-                // -> Because passing `numberOfGlyphs` to `lineFragmentUsedRect(forGlyphAt:effectiveRange:)` is invalid
-                //    and causes the warning: `_NSLayoutTreeLineFragmentUsedRectForGlyphAtIndex`. (2019-02)
-                let safeGlyphIndex = min(glyphRange.location, self.numberOfGlyphs - 1)
+                let safeGlyphIndex = self.isValidGlyphIndex(glyphRange.location) ? glyphRange.location : glyphRange.location - 1
                 
                 var effectiveLineRange: NSRange = .notFound
                 let usedRect = self.lineFragmentUsedRect(forGlyphAt: safeGlyphIndex, effectiveRange: &effectiveLineRange, withoutAdditionalLayout: true)

        
        // get base selection rects in the origin line
        let baseIndex = (affinity == .downstream) ? glyphRanges.last!.lowerBound : glyphRanges.first!.upperBound
        var baseLineRange: NSRange = .notFound
        layoutManager.lineFragmentRect(forGlyphAt: min(baseIndex, layoutManager.numberOfGlyphs - 1), effectiveRange: &baseLineRange, withoutAdditionalLayout: true)
        let rowBounds = glyphRanges
            .filter { baseLineRange.touches($0) }
            .map { layoutManager.minimumRowBounds(of: $0, in: textContainer) }

        guard
            !(affinity == .downstream && effectiveGlyphRange.lowerBound == 0),
            !(affinity == .upstream && (
                (layoutManager.extraLineFragmentTextContainer == nil && !layoutManager.isValidGlyphIndex(effectiveGlyphRange.upperBound)) ||
                (layoutManager.extraLineFragmentTextContainer != nil && insertionRanges.last?.lowerBound == self.string.length)))
            else { return }
        
