Skip to content

Commit 01a5958

Browse files
committed
error catch for commands
1 parent 32d8842 commit 01a5958

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/main/clojure/com/github/clojure_lsp/intellij/client.clj

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@
4747
deref))))
4848

4949
(defn execute-command [^String name ^String text ^List args ^Project project]
50-
(-> (CommandExecutor/executeCommand
51-
(doto (LSPCommandContext. (Command. text name args) project)
52-
(.setPreferredLanguageServerId "clojure-lsp")))
53-
(.response)
54-
deref))
50+
(try
51+
(-> (CommandExecutor/executeCommand
52+
(doto (LSPCommandContext. (Command. text name args) project)
53+
(.setPreferredLanguageServerId "clojure-lsp")))
54+
(.response)
55+
deref)
56+
(catch Exception e
57+
(logger/error "Error appllying command" name (with-out-str (.printStackTrace e))))))

src/main/clojure/com/github/clojure_lsp/intellij/extension/register_actions_startup.clj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
{:name "kill-sexp" :text "Kill sexpr" :description "Kill current sexpr (Paredit)" :keyboard-shortcut {:first "alt K" :replace-all true}}])
7878

7979
(defn ^:private on-action-performed [command-name text project ^AnActionEvent event]
80-
(when-let [editor ^Editor (.getData event CommonDataKeys/EDITOR)]
80+
(when-let [editor ^Editor (.getData event CommonDataKeys/EDITOR_EVEN_IF_INACTIVE)]
8181
(let [[line character] (util/editor->cursor-position editor)]
8282
(tasks/run-background-task!
8383
project
@@ -129,4 +129,7 @@
129129
(logger/info "Actions registered"))
130130

131131
(comment
132-
(-runActivity nil (first (db/all-projects))))
132+
(do
133+
(.unregisterAction (ActionManager/getInstance) "ClojureLSP.ForwardSlurp")
134+
(.unregisterAction (ActionManager/getInstance) "ClojureLSP.ForwardBarf")
135+
(-runActivity nil (first (db/all-projects)))))

0 commit comments

Comments
 (0)