Skip to content

Commit cade685

Browse files
Fix cljs type not set correctly (#3282)
* Fix cljs type not set correctly I introduced a bug with 24b9891 that made cljs repls not upgrade automatically anymore to cljs (repl-type). What actually happened was that after the init function, it was set an ultimate time, because of the "demunge" eval call I added. 1. Move the connection capability block in fron of =cider-nrepl-init-function=, this would by itself already fix it because then we would eval as clj repl and in the end once as cljs repl (which sets the repl-type see cider-repl--state-handler) 2. do not make the "demunge" eval call at all, when we already know the repl is going to be cljs (cljs or pending-cljs). (This would by itself also be a fix). * Fix cljs type not set correctly I introduced a bug with 24b9891 that made cljs repls not upgrade automatically anymore to cljs (repl-type). What actually happened was that after the init function, it was set an ultimate time, because of the "demunge" eval call I added. 1. Move the connection capability block in fron of =cider-nrepl-init-function=, this would by itself already fix it because then we would eval as clj repl and in the end once as cljs repl (which sets the repl-type see cider-repl--state-handler) 2. do not make the "demunge" eval call at all, when we already know the repl is going to be cljs (cljs or pending-cljs). (This would by itself also be a fix). * Fix format
1 parent 5ad3f38 commit cade685

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

cider-connection.el

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,26 @@ See command `cider-mode'."
303303
(unless (cider-sessions)
304304
(cider-disable-on-existing-clojure-buffers)))
305305

306+
(defun cider--set-connection-capabilities (&optional conn-buffer)
307+
"Set `cider-connection-capabilities' for CONN-BUFFER during repl init.
308+
See `cider-connection-capabilities'."
309+
(with-current-buffer (or conn-buf (current-buffer))
310+
(setf cider-connection-capabilities
311+
(append
312+
(pcase (cider-runtime)
313+
('clojure '(clojure jvm-compilation-errors))
314+
('babashka '(babashka jvm-compilation-errors))
315+
(_ '()))
316+
(when
317+
(or
318+
(member cider-repl-type '(cljs pending-cljs))
319+
;; This check is currently basically for nbb.
320+
;; See `cider-sync-tooling-eval', but it is defined on a higher layer
321+
(nrepl-dict-get
322+
(nrepl-sync-request:eval "cljs.core/demunge" (current-buffer) (cider-current-ns) 'tooling)
323+
"value"))
324+
'(cljs))))))
325+
306326
(declare-function cider--debug-init-connection "cider-debug")
307327
(declare-function cider-repl-init "cider-repl")
308328
(declare-function cider-nrepl-op-supported-p "cider-client")
@@ -339,25 +359,14 @@ buffer."
339359
;; first.
340360
(cider--debug-init-connection))
341361

362+
(cider--set-connection-capabilities)
363+
342364
(when cider-repl-init-function
343365
(funcall cider-repl-init-function))
344366

345367
(when cider-auto-mode
346368
(cider-enable-on-existing-clojure-buffers))
347369

348-
(setf cider-connection-capabilities
349-
(append
350-
(pcase (cider-runtime)
351-
('clojure '(clojure jvm-compilation-errors))
352-
('babashka '(babashka jvm-compilation-errors))
353-
(_ '()))
354-
(when
355-
;; see `cider-sync-tooling-eval', but it is defined on a higher layer
356-
(nrepl-dict-get
357-
(nrepl-sync-request:eval "cljs.core/demunge" (current-buffer) nil 'tooling)
358-
"value")
359-
'(cljs))))
360-
361370
(run-hooks 'cider-connected-hook)))))
362371

363372
(defun cider--disconnected-handler ()

0 commit comments

Comments
 (0)