 (ns ^:figwheel-always parinfer.core
   (:require
-    [clojure.string :as string :refer [split-lines]]
+    [clojure.string :as string :refer [split-lines join]]
     [om.core :as om :include-macros true]
     [om.dom :as dom :include-macros true]
     [sablono.core :refer-macros [html]]))

                          (in-code? stack)
                          (not (whitespace? ch)))
                 {:line-no line-no
                  :x-pos x-pos})
        result (cond-> result insert (assoc :insert insert))]
    result))


(defn update-text!
  [cursor-index text]
  (try
    (let [{:keys [stack lines]} (parse-text text)]
      (swap! app-state assoc :stack stack)
      (swap! app-state assoc :text text)
      (swap! app-state assoc :full-text (join "\n" lines)))
    (catch :default e
      (println "EXCEPTION:" e)
      nil ;; don't update the text
