           (mouseExited [this e] nil)
           (mousePressed [this e] nil)
           (mouseReleased [this e]
-            (mwm/update-cursor-position! edit-history (.getCaretPosition text-area))))))
+            (mwm/update-cursor-position! edit-history (get-cursor-position text-area))))))
     (reset! edit-history nil))
   text-area)
 

              (contains? #{KeyEvent/VK_DOWN KeyEvent/VK_UP
                           KeyEvent/VK_RIGHT KeyEvent/VK_LEFT}
                         (.getKeyCode e))
              (mwm/update-cursor-position! edit-history (.getCaretPosition text-area))
              
              (not (or (contains? #{KeyEvent/VK_SHIFT KeyEvent/VK_CONTROL
                                    KeyEvent/VK_ALT KeyEvent/VK_META}

    (let [old-text (.getText text-area)]
      ; use paren mode to preprocess the code
      (when preprocess?
        (->> (get-parinfer-state text-area true)
             (refresh-content! text-area)
             (mwm/update-edit-history! edit-history)))
      (.discardAllEdits text-area)
