 
 
 (defn case-sensitivity [case-sensitive? dictionary-item input]
-  (if case-sensitive?
-    (string/starts-with? dictionary-item input)
-    (string/starts-with? (string/lower-case dictionary-item) (string/lower-case input))))
+  (if (= input "")
+    nil
+    (if case-sensitive?
+      (string/starts-with? dictionary-item input)
+      (string/starts-with? (string/lower-case dictionary-item) (string/lower-case input)))))
 
 (defn items-to-complete
   "List of the items to autocomplete by given input and list of the all items"

      ""
      current-word-item)))

(defn completions
  "Autocomplete options for word"
  [input dictionary options]
  (let [last-string (last (string/split input #" "))
        trim-chars (:trim-chars options)
        sort-fn (:sort-fn options)
        case-sensitive? (:case-sensitive? options)
        complete-items (items-to-complete case-sensitive? dictionary last-string)]
    (vec
     (if trim-chars
       (if (= (first last-string) (re-find (utils/str-to-pattern trim-chars) (str (first last-string))))
         (->> 1
              (subs last-string)
              (items-to-complete case-sensitive? dictionary)
              (sort-by sort-fn))
         (sort-by sort-fn complete-items))
       (sort-fn complete-items)))))

(defn words-to-index
  "Words to change index"

  [index trim-chars text word-to-complete]
  (->> (update-in (string/split text #" ") [(index-of-word index text)]
                  #(complete-word-with-trimmed-chars (index-in-word index text)
                                                     %
                                                     word-to-complete
                                                     trim-chars))
       (string/join " ")))
