Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(undo): undo after pair character input #1194

Merged
merged 4 commits into from
May 20, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix #559: undo after pair character input
  • Loading branch information
datokrat committed May 18, 2021
commit f7bc9549f7e8be52c70c916d2544c13d17cb564e
10 changes: 8 additions & 2 deletions src/cljs/athens/views/blocks/textarea_keydown.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,10 @@
(= selection "") (let [new-str (str head key close-pair tail)
new-idx (inc start)]
(swap! state assoc :string/local new-str)
(set! (.-value target) new-str)
(.. js/document (execCommand
tangjeff0 marked this conversation as resolved.
Show resolved Hide resolved
"insertText"
false
(str key close-pair)))
(set-cursor-position target new-idx)
(when (>= (count (:string/local @state)) 4)
(let [four-char (subs (:string/local @state) (dec start) (+ start 3))
Expand All @@ -592,7 +595,10 @@
(not= selection "") (let [surround-selection (surround selection key)
new-str (str head surround-selection tail)]
(swap! state assoc :string/local new-str)
(set! (.-value target) new-str)
(.. js/document (execCommand
"insertText"
false
surround-selection))
(set! (.-selectionStart target) (inc start))
(set! (.-selectionEnd target) (inc end))
(let [four-char (str (subs (:string/local @state) (dec start) (inc start))
Expand Down