     (getChildAt [i] (commit-node (nth commits i)))
     (getChildCount [] (count commits))))
 
+(defn selected-commit
+  [^JTree sidebar]
+  (some-> sidebar .getSelectionPath .getLastPathComponent .getUserObject))
+
 (defn selected-row
   [^JTree sidebar commits]
-  (when-let [^RevCommit selected-commit (some-> sidebar
-                                                .getSelectionPath
-                                                .getLastPathComponent
-                                                .getUserObject)]
+  (when-let [^RevCommit selected-commit (selected-commit sidebar)]
     (->> (map-indexed vector commits)
          (filter (fn [[index ^RevCommit commit]]
                    (= (some-> commit .getId)

        (.setSelectionMode TreeSelectionModel/SINGLE_TREE_SELECTION))))

(defn update-content!
  [content ^Git git ^RevCommit commit]
  (doto content
    (.setText (create-html git commit))
    (.setCaretPosition 0)))

(defn update-sidebar!
  ([]

          (reify TreeSelectionListener
            (valueChanged [this e]
              (->> (some-> e .getPath .getLastPathComponent .getUserObject)
                   (update-content! sidebar content git)))))
        (.setSelectionRow (or selected-row 0))))))

(def ^:dynamic *widgets* [])
