     }
 
     override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
-        if !completionActive {
+        if !shouldApplyCompletion {
             super.touchesEnded(touches, withEvent: event)
         } else {
             applyCompletion()
 
             // Set the current position to the end of the text.
             selectedTextRange = textRangeFromPosition(endOfDocument, toPosition: endOfDocument)
+
+            shouldApplyCompletion = !shouldApplyCompletion
         }
     }
 }

    private var completionActive = false
    private var canAutocomplete = true
    private var enteredText = ""
    private var previousSuggestion = ""
    private var notifyTextChanged: (() -> ())? = nil

    }

    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        shouldApplyCompletion = completionActive
        if !completionActive {
            super.touchesBegan(touches, withEvent: event)
        }
