     {:x (.-cursorX res) :text (.-text res)}))
 
 (defn indent-mode [text x line]
-  (let [res (Parinfer/indentMode text (int x) (int line) nil)]
+  (let [^ParinferResult res (Parinfer/indentMode text (int x) (int line) nil)]
     {:x (.-cursorX res) :text (.-text res)}))
 
+(defn row-col->index
+  [text row col]
+  (let [s (join \newline (take row (split text #"\n")))
+        index (+ (count s) (inc col))]
+    index))
+
 (defn run-parinfer!
-  [text-area paren-mode?]
+  [^TextEditorPane text-area paren-mode?]
   (let [old-pos (.getCaretPosition text-area)
         old-x (.getCaretOffsetFromLineStart text-area)
         old-line (.getCaretLineNumber text-area)

                   (if (italicize-fn) "italic" "normal")
                   (-> e-path io/file .getName)))
         (cons "<center>PgUp PgDn</center>")
         (clojure.string/join "<br/>")
         shortcuts/wrap-hint-text
         (s/editor-pane :editable? false :content-type "text/html" :text)
         (shortcuts/create-hint! true editor-pane)

                 (indent-mode old-text old-x old-line))
        new-text (:text result)
        new-x (:x result)
        new-pos (row-col->index new-text old-line new-x)]
    (.setText text-area new-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)]
