         }
     }
 
-    var normalizedEnteredText: String {
-        return enteredText.lowercaseString.stringByTrimmingLeadingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
-    }
-
     override var text: String? {
         didSet {
             // SELtextDidChange is not called when directly setting the text property, so fire it manually.

        selectedTextRange = textRangeFromPosition(beginningOfDocument, toPosition: beginningOfDocument)
    }

    /// Commits the completion by setting the text and removing the highlight.
    private func applyCompletion() {
        if completionActive {


    private func removeCompletionIfRequiredForEnteredString(string: String) {
        // If user-entered text does not start with previous suggestion then remove the completion.

        let actualEnteredString = enteredText + string
        // Detecting the keyboard type, and remove hightlight in "zh-Hans" and "ja-JP"
        if !previousSuggestion.startsWith(normalizeString(actualEnteredString)) ||
            UIApplication.sharedApplication().textInputMode?.primaryLanguage == "zh-Hans" ||
            UIApplication.sharedApplication().textInputMode?.primaryLanguage == "ja-JP" {
            removeCompletion()
        }
        enteredText = actualEnteredString
