     /// - Returns: Returns the index within the list.
     ///
     func itemNumber(in list: TextList, at location: Int) -> Int {
+        guard
+            let paragraphStyle = attribute(NSParagraphStyleAttributeName, at: location, effectiveRange: nil) as? ParagraphStyle
+            else {
+                return NSNotFound
+        }
+        let listDepth = paragraphStyle.textLists.count
         guard let rangeOfList = range(of:list, at: location) else {
             return NSNotFound
         }

        else {
            return nil
        }
        var resultRange = effectiveRange
        //Note: The effective range will only return the range of the in location NSParagraphStyleAttributed 
        // but this can be different on preceding or suceeding range but is the same TextList, 
        // so we need to expand the range to grab all the TextList coverage.
        while resultRange.location > 0 {
            if
                let paragraphStyle = attribute(NSParagraphStyleAttributeName, at: resultRange.location-1, longestEffectiveRange: &effectiveRange, in: targetRange) as? ParagraphStyle,
                let foundList = paragraphStyle.textLists.last,
                foundList == list {
                resultRange = resultRange.union(withRange: effectiveRange)
            } else {
                break;
            }
        }
        while resultRange.endLocation < self.length {
            if
                let paragraphStyle = attribute(NSParagraphStyleAttributeName, at: resultRange.endLocation, longestEffectiveRange: &effectiveRange, in: targetRange) as? ParagraphStyle,
                let foundList = paragraphStyle.textLists.last,
                foundList == list {
                resultRange = resultRange.union(withRange: effectiveRange)
            } else {
                break;
            }
        }

        return resultRange
    }

            if NSLocationInRange(location, range) {
                return numberInList
            }
            if let paragraphStyle = attribute(NSParagraphStyleAttributeName, at: range.location, effectiveRange: nil) as? ParagraphStyle,
               listDepth == paragraphStyle.textLists.count {
                numberInList += 1
            }
        }
        return NSNotFound
    }
