     func textChanged() {
         guard let text = view?.m_text else { return }
 
-        let deleting = view?.m_attributedText?.string.characters.count < previousCharacterCount
-        if let range = rangeOfMention(atIndex: recentCharacterRange.location) {
-            deleting ? deleteMention(inRange: range) : undoMention(inRange: range)
+        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 }
+            if let length = self.mentionCache[value] where length != range.length + 1 {
+                self.deleteMention(inRange: range)
+                self.mentionCache.removeValueForKey(value)
+                stop.memory = true
+            }
         }
 
         if let query = mentionQuery(fromString: text) {

        let mutableEncodedString = NSMutableAttributedString(attributedString: user.encodedAttributedString())
        mutableEncodedString.addAttributes([NSFontAttributeName : font, NSForegroundColorAttributeName : MentionColor], range: NSRange(location: 0, length: mutableEncodedString.length))
        text.replaceCharactersInRange(mentionRange!, withAttributedString: mutableEncodedString)
        let typingAttributes = view?.m_typingAttributes
        setAttributedText(text, cursorLocation: mentionRange!.location + mutableEncodedString.length)
        view?.m_typingAttributes = typingAttributes

    private let originalAutoCorrectionType: UITextAutocorrectionType!
    private var userNameMatches: [MentionUser]?
    private var previousCharacterCount = 0

    private var mentionCache = [Int : Int]()

    private var recentCharacterRange: NSRange {
        guard let
            beginning = view?.beginningOfDocument,
