 (ns parinfer.editor
+  (:require-macros
+    [cljs.core.async.macros :refer [go go-loop]])
   (:require
+    [cljs.core.async :refer [<! timeout chan]]
     [clojure.string :as string :refer [join]]
     [parinfer.formatter :refer [format-text]]
     [cljsjs.codemirror]

             (= (.getValue cm) (join "\n" (.-text change))))
    (.cancel change)))

(defn on-change
  "Called after any change is applied to the editor."
  [cm change]
  (when (not= "setValue" (.-origin change))
    (fix-text! cm)
    (update-cursor! cm change)
    (set-frame-updated! cm true)))


(def frame-updates (atom {}))

(def empty-recording
  {:changes []
   :init-value nil
   :last-time nil
   :recording? false})

(defonce vcr
  (atom {}))

(defn before-change
  "Called before any change is applied to the editor."
  [cm change]
