             return false
         } else if text.utf16.count > 1 {
             // Pasting
-            _ = mentions |> mentionBeingEdited(at: range) |> clearMention()
+            _ = mentions |> mentionBeingEdited(at: range) >=> clearMention()
 
             textView.delegate = nil
             // The following snippet is because if you click on a predictive text without this snippet
             // the predictive text will be added twice.
             let originalText = mentionsTextView.attributedText
-            _ = mentionsTextView.attributedText |> replace(charactersIn: range, with: text)
+            _ = mentionsTextView.attributedText
+                |> replace(charactersIn: range, with: text)
             mentionsTextView.attributedText = originalText
-            mentionsTextView.attributedText |>
-                replace(charactersIn: range, with: text) |>
-                selectRange(on: mentionsTextView)
-
-            mentionsTextView.attributedText |> apply(defaultTextAttributes, range: range.adjustLength(for: text))
+            mentionsTextView.attributedText
+                |> replace(charactersIn: range, with: text)
+                |> selectRange(on: mentionsTextView)
+
+            mentionsTextView.attributedText
+                |> apply(defaultTextAttributes, range: range.adjustLength(for: text))
             mentionsTextView.scrollRangeToVisible(mentionsTextView.selectedRange)
-            mentions |> adjusted(forTextChangeAt: range, text: text)
+            mentions = mentions |> adjusted(forTextChangeAt: range, text: text)
             adjust(textView, range: textView.selectedRange)
             textView.delegate = self
 

    @discardableResult private func shouldAdjust(_: UITextView, range: NSRange, text: String) -> Bool {
        var shouldAdjust = true

        if mentions |> mentionBeingEdited(at: range) |> clearMention() {
            mentionsTextView.attributedText |>
                replace(charactersIn: range, with: text) |>
                selectRange(on: mentionsTextView)
            shouldAdjust = false
        }

        mentions |> adjusted(forTextChangeAt: range, text: text)

        return shouldAdjust
    }

        let string = String(mentionsTextView.text[startIndex ..< endIndex])

        var textBeforeTrigger = " "
        let rangeTuple = string.range(of: triggers, options: .backwards)
        let location = rangeTuple.range.location

        mentionEnabled = false
        let trigger = rangeTuple.foundString

        if location != NSNotFound {
            (mentionEnabled, textBeforeTrigger) = mentionsTextView.text.isMentionEnabledAt(location)
        }

        if mentionEnabled {
            var mentionString: String = ""
            if searchSpaces {
                let startIndex = mentionsTextView.text.index(mentionsTextView.text.startIndex, offsetBy: location)
                let endIndex = mentionsTextView.text.index(startIndex, offsetBy: NSMaxRange(textView.selectedRange) - location)
                mentionString = String(mentionsTextView.text[startIndex ..< endIndex])
            } else if let stringBeingTyped = string.components(separatedBy: textBeforeTrigger).last,
                let stringForMention = stringBeingTyped.components(separatedBy: " ").last,
