                        (update-in [:lines line-no] remove-str-range start end)
                        (assoc :backup backup :stack stack))
 
-
             insert-line? (= (:line-no insert) line-no)
             result (cond-> result
                      insert-line? (update-in [:insert :x-pos] min start))]

      (html
        [:div
         [:textarea
          {:on-change (fn [evt]
                        (let [target (.-target evt)]
                          (update-text! (.-selectionStart target) (.-value target))))}]
         [:pre.computed (:full-text data)]]))))

;; hack to initialize the state on first load (not when reloading)


(defn process-char
  "Update the given result by processing the given character and its position."
  [{:keys [stack line-no track-indent? cursor-x cursor-line] :as result} [x-pos ch]]

  (let [result (process-delim-trail result [x-pos ch])
        backup (:backup result)
