 (defn get-top-level-form
   ([ed] (get-top-level-form ed (editor/->cursor ed)))
   ([ed loc]
-   (if-let [[start end] (some->> (get-bounds-matching ed loc)
-                                 (iterate (partial get-next-bounds-matching ed))
-                                 (take-while identity)
-                                 last)]
-
-     {:form-str (editor/range ed start (update-in end [:ch] inc))
-      :start start
-      :end (update-in end [:ch] inc)}
+   (reset! loc-counts {:start 0
+                       :end 0})
+   (if-let [[start end] (time (some->> (get-bounds-matching ed loc)
+                                       (iterate (partial get-next-bounds-matching ed))
+                                       (take-while identity)
+                                       last))]
+
+     (do
+       {:form-str (editor/range ed start (update-in end [:ch] inc))
+       :start start
+       :end (update-in end [:ch] inc)})
      (let [line (:line loc)
            line-str (editor/line ed (:line loc))]
        {:form-str line-str

;; Improved form selection utils
;; ==================================

(defn whitespace? [ch]
  (some #{\space \newline \tab} right-char))

(defn- end-pair? [ch]
  (some #{\) \} \]} ch))

       (str-contains? t "comment") true
       (and (str-contains? t "string")
            (not
             (and (end-pair? ch) (= \" left-ch) (not (= "string" (editor/->token-type ed (editor/adjust-loc loc 1))))))) true
       :else false))))


