         state (r/atom {:text thread-text
                        :force-close? false
                        :highlighted-result-index 0
-                       :results nil})
+                       :results nil
+                       :pos 0})
 
         reset-state! (fn []
                        (swap! state assoc

       (fn [c]
         (let [config (r/props c)]
           (go (loop []
                 (let [[text ch] (alts! [throttled-autocomplete-chan kill-chan])]
                   (when (= ch throttled-autocomplete-chan)
                     (when-not (inside-code-block? text)
                       (set-results!
                         (seq (mapcat (fn [e] (e text)) @autocomplete-engines)))
                       (highlight-first!))
                     (recur)))))
           (go (loop []
                 (let [[v ch] (alts! [throttled-thread-text-chan

        autocomplete-on-change
        (fn [{:keys [on-change]}]
          (fn [e]
            (let [cursor-pos (.. e -target -selectionStart)]
              (handle-text-change! cursor-pos (.. e -target -value))
              (swap! state assoc :pos cursor-pos))
            (on-change e)))]

    (r/create-class
