     var view: T?
     var tableView: UITableView?
     weak var delegate: MentionComposerDelegate?
-    private var mentionRange = NSRange(location: 0, length: 0)
     private let originalTextColor: UIColor
-    private var userNameMatches = [MentionUserType]()
-    private var lengthOfMentionPerId = [Int : Int]()
+    private var mentionRange           = NSRange(location: 0, length: 0)
+    private var userNameMatches        = [MentionUserType]()
+    private var lengthOfMentionPerId   = [Int : Int]()
+    private var requestingMentionUsers = false
 
     /// Returns the range of the most recently typed character
     private var recentCharacterRange: NSRange {

        tableView.delegate = self
        tableView.dataSource = self
        tableView.registerNib(UINib(nibName: "MentionTableViewCell", bundle: NSBundle(forClass: MentionTableViewCell.self)), forCellReuseIdentifier: MentionCellIdentifier)
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "textChanged", name: UITextFieldTextDidChangeNotification, object: view)
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "textChanged", name: UITextViewTextDidChangeNotification, object: view)
    }


        // Check for a mention query
        if let query = mentionQuery(fromString: text) {
            requestingMentionUsers = true
            refreshTableView()

            delegate?.usersMatchingQuery(query as String) { [weak self] (users) -> Void in
                guard self?.requestingMentionUsers == true else { return }
                
                self?.requestingMentionUsers = false

                if let users = users {
                    self?.userNameMatches = users
                }
                else {
                    self?.userNameMatches.removeAll()
                }

                self?.refreshTableView()
            }
        }
        else {
            requestingMentionUsers = false
            userNameMatches.removeAll()
            refreshTableView()
        }
