mirror of
https://github.com/logseq/logseq.git
synced 2026-04-27 15:45:00 +00:00
fix: can't move forward if there's only one character in the editor
close #3952
This commit is contained in:
@@ -71,8 +71,9 @@
|
||||
([input n]
|
||||
(when input
|
||||
(let [{:keys [pos]} (get-caret-pos input)
|
||||
pos (if (= n 1)
|
||||
(util/safe-inc-current-pos-from-start (.-value input) pos)
|
||||
pos (if (and (= n 1) (not (zero? pos)))
|
||||
(or (util/safe-inc-current-pos-from-start (.-value input) pos)
|
||||
(inc pos))
|
||||
(+ pos n))]
|
||||
(move-cursor-to input pos)))))
|
||||
|
||||
@@ -84,7 +85,8 @@
|
||||
(let [{:keys [pos]} (get-caret-pos input)
|
||||
pos (if (= n 1)
|
||||
(util/safe-dec-current-pos-from-end (.-value input) pos)
|
||||
(- pos n))]
|
||||
(- pos n))
|
||||
pos (max 0 (or pos (dec pos)))]
|
||||
(move-cursor-to input pos)))))
|
||||
|
||||
(defn- get-input-content&pos
|
||||
|
||||
Reference in New Issue
Block a user