Skip to content

Commit

Permalink
fix: handle shortcuts nil in config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Weihua Lu authored and tiensonqin committed Jun 23, 2021
1 parent 809984e commit 53b2d66
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/frontend/modules/shortcut/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[frontend.handler.config :as config]
[frontend.handler.notification :as notification]
[frontend.modules.shortcut.data-helper :as dh]
[frontend.state :as state]
[frontend.util :as util]
[goog.events :as events]
[goog.ui.KeyboardShortcutHandler.EventType :as EventType]
Expand Down Expand Up @@ -182,7 +183,9 @@
(let [k (first args)
keystroke (str/trim @local)]
(when-not (empty? keystroke)
(config/set-config! [:shortcuts k] keystroke)))
(config/set-config! :shortcuts (merge
(:shortcuts (state/get-config))
{k keystroke}))))

(when-let [^js handler (::key-record-handler state)]
(.dispose handler))
Expand Down
2 changes: 2 additions & 0 deletions templates/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
;; :editor/down ["ctrl+j" "down"]
;; :editor/left ["ctrl+h" "left"]
;; :editor/right ["ctrl+l" "right"]}
:shortcuts {}

;; Whether to show command doc on hover
:ui/show-command-doc? true

Expand Down

0 comments on commit 53b2d66

Please sign in to comment.