mirror of https://github.com/logseq/logseq
fix: gracefully handle invalid jump
invalid selection was resulting in errors and jumps persisting in weird wayspull/11049/merge
parent
636f9554ab
commit
778f2c1688
|
@ -3,7 +3,8 @@
|
|||
(:require [frontend.state :as state]
|
||||
[dommy.core :as d]
|
||||
[clojure.string :as string]
|
||||
[frontend.util :as util]))
|
||||
[frontend.util :as util]
|
||||
[frontend.handler.notification :as notification]))
|
||||
|
||||
(defonce *current-keys (atom nil))
|
||||
(defonce *jump-data (atom {}))
|
||||
|
@ -62,17 +63,19 @@
|
|||
|
||||
(defn get-trigger
|
||||
[triggers key]
|
||||
(when-let [idx (.indexOf @*current-keys key)]
|
||||
(nth triggers idx)))
|
||||
(let [idx (.indexOf @*current-keys key)]
|
||||
(when (>= idx 0) (nth triggers idx))))
|
||||
|
||||
(defn trigger!
|
||||
[key e]
|
||||
(let [{:keys [triggers _mode]} @*jump-data]
|
||||
(when-let [trigger (get-trigger triggers (string/trim key))]
|
||||
(let [trigger (get-trigger triggers (string/trim key))]
|
||||
(util/stop e)
|
||||
(state/clear-selection!)
|
||||
(exit!)
|
||||
(.click trigger))))
|
||||
(if trigger
|
||||
(.click trigger)
|
||||
(notification/show! "Invalid jump" :error true)))))
|
||||
|
||||
(defn jump-to
|
||||
[]
|
||||
|
|
Loading…
Reference in New Issue