        :text-area text-area
        :close-fn! (fn [])
        :italicize-fn #(.isDirty text-area)
-       :should-remove-fn #(not (.exists (io/file path)))})))
+       :should-remove-fn #(not (.exists (io/file path)))
+       :edit-history edit-history})))
 
 (def ^:dynamic *types* [:text :logcat :git])
 

        new-text (:text result)
        new-x (:x result)
        new-pos (row-col->index new-text old-line new-x)]
    (.replaceRange text-area new-text 0 (count old-text))
    (.setCaretPosition text-area new-pos)))

(defn init-parinfer!
  [^TextEditorPane text-area extension]
  (when (contains? utils/clojure-exts extension)
    ; use paren mode to preprocess the code
    (let [old-text (.getText text-area)]
      (run-parinfer! text-area true)
      (.discardAllEdits text-area)
      (.setDirty text-area (not= old-text (.getText text-area))))
    ; add a listener to run indent mode when a key is pressed
    (.addKeyListener text-area
      (reify KeyListener
        (keyReleased [this e]
          (when-not (or (contains? #{KeyEvent/VK_DOWN KeyEvent/VK_UP
                                     KeyEvent/VK_RIGHT KeyEvent/VK_LEFT
                                     KeyEvent/VK_SHIFT KeyEvent/VK_CONTROL
                                     KeyEvent/VK_ALT KeyEvent/VK_META}
                                   (.getKeyCode e))
                        (.isControlDown e)
                        (.isMetaDown e))
            (run-parinfer! text-area (= (.getKeyCode e) KeyEvent/VK_ENTER))))
        (keyTyped [this e] nil)
        (keyPressed [this e] nil))))
  text-area)

(defn create-text-area
  ([]
    (doto (proxy [TextEditorPane] []
            (setMarginLineEnabled [enabled?]
              (proxy-super setMarginLineEnabled enabled?))
            (setMarginLinePosition [size]
              (proxy-super setMarginLinePosition size))
            (processKeyBinding [ks e condition pressed]
              (proxy-super processKeyBinding ks e condition pressed)))
      (.setAntiAliasingEnabled true)
      apply-settings!))
  ([path]
    (let [extension (utils/get-extension path)]
      (doto (create-text-area)
        (.load (FileLocation/create path) "UTF-8")
        .discardAllEdits
        (.setSyntaxEditingStyle (get utils/styles extension))

(defmethod create-editor :text [_ path]
  (when (utils/valid-file? (io/file path))
    (let [; create the text editor and the pane that will hold it
          edit-history (atom nil)
          text-area (create-text-area path edit-history)
          extension (utils/get-extension path)
          clojure? (contains? utils/clojure-exts extension)
          completer (completions/create-completer text-area extension)
