Skip to content

Commit ea61ff3

Browse files
committed
retains cursor position even when resetting text
1 parent ae0c043 commit ea61ff3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/cljs/re_codemirror/core.cljs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
[this cm _]
2626
(let [{:keys [value]} (conf this)]
2727
(when-not (= value (.getValue cm))
28-
(.setValue cm value))))
28+
(let [doc (.getDoc cm)
29+
from (.getCursor doc "from")
30+
to (.getCursor doc "to")]
31+
(.setValue cm value)
32+
(.setSelection dock from to)))))
2933

3034
(defn codemirror
3135
[]

0 commit comments

Comments
 (0)