             setAttributedText(mutableString, cursorLocation: recentCharacterRange.location + 1)
         }
 
+        // Check for a mention query
         if let query = mentionQuery(fromString: text) {
             delegate?.usersMatchingQuery(query as String) { [weak self] (users) -> Void in
                 if let users = users {

            self.mentionCache.removeValueForKey(mentionId)
        }

        guard let updatedTextLength = view?.m_text.characters.count else { return }
        var rangeToUpdate: NSRange?
        view?.m_attributedText?.enumerateAttribute(NSForegroundColorAttributeName, inRange: NSRange(location: 0, length: updatedTextLength), options: NSAttributedStringEnumerationOptions(rawValue: 0)) { (value, range, stop) -> Void in

    func textChanged() {
        guard let text = view?.m_text else { return }

        // Delete mentions if either of the following conditions are met:
        // 1. A character in the mention was deleted
        // 2. A character was added within the range of the mention
        var removedMentionIds = Set<Int>()
        view?.m_attributedText?.enumerateAttribute(MentionAttributes.UserId, inRange: NSRange(location: 0, length: text.characters.count), options: NSAttributedStringEnumerationOptions(rawValue: 0)) { (value, range, stop) -> Void in
            guard let value = value as? Int else { return }
