Skip to content

Commit a8b5c40

Browse files
committed
Reify cider-cljs-pending separate from repl-type
1 parent 228d2fe commit a8b5c40

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

cider-connection.el

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,13 @@ See `cider-connection-capabilities'."
315315
(_ '()))
316316
(when
317317
(or
318-
(member cider-repl-type '(cljs pending-cljs))
318+
(eq cider-repl-type 'cljs)
319319
;; This check is currently basically for nbb.
320320
;; 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"))
321+
(progn
322+
(nrepl-dict-get
323+
(nrepl-sync-request:eval "cljs.core/demunge" (current-buffer) nil 'tooling)
324+
"value")))
324325
'(cljs))))))
325326

326327
(declare-function cider--debug-init-connection "cider-debug")
@@ -762,10 +763,17 @@ Session name can be customized with `cider-session-name-template'."
762763
(defvar-local cider-repl-type nil
763764
"The type of this REPL buffer, usually either clj or cljs.")
764765

766+
(defvar-local cider-cljs-repl-pending nil
767+
"Is the cljs repl currently pending?")
768+
765769
(defun cider-repl-type (repl-buffer)
766770
"Get REPL-BUFFER's type."
767771
(buffer-local-value 'cider-repl-type repl-buffer))
768772

773+
(defun cider-cljs-pending-p (repl-buffer)
774+
"Returns non nil when REPL-BUFFER is currently a pending cljs repl."
775+
(buffer-local-value 'cider-cljs-repl-pending repl-buffer))
776+
769777
(defun cider-repl-type-for-buffer (&optional buffer)
770778
"Return the matching connection type (clj or cljs) for BUFFER.
771779
BUFFER defaults to the `current-buffer'. In cljc buffers return
@@ -812,13 +820,13 @@ PARAMS is a plist as received by `cider-repl-create'."
812820
(let* ((proj-dir (plist-get params :project-dir))
813821
(host (plist-get params :host))
814822
(port (plist-get params :port))
815-
(cljsp (member (plist-get params :repl-type) '(cljs pending-cljs)))
823+
(cljsp (member (plist-get params :repl-type) '(cljs)))
816824
(scored-repls
817825
(delq nil
818826
(mapcar (lambda (b)
819827
(let ((bparams (cider--gather-connect-params nil b)))
820828
(when (eq cljsp (member (plist-get bparams :repl-type)
821-
'(cljs pending-cljs)))
829+
'(cljs)))
822830
(cons (buffer-name b)
823831
(+
824832
(if (equal proj-dir (plist-get bparams :project-dir)) 8 0)
@@ -866,8 +874,9 @@ function with the repl buffer set as current."
866874
mode-name nil
867875
cider-session-name ses-name
868876
nrepl-project-dir (plist-get params :project-dir)
869-
;; REPLs start with clj and then "upgrade" to a different type
877+
;; Cljs repls are pending until they are upgraded. See cider-repl--state-handler
870878
cider-repl-type (plist-get params :repl-type)
879+
cider-cljs-repl-pending (plist-get params :cider-cljs-repl-pending)
871880
;; ran at the end of cider--connected-handler
872881
cider-repl-init-function (plist-get params :repl-init-function)
873882
cider-launch-params params)
@@ -985,7 +994,9 @@ throw an error if no linked session exists."
985994
(sesman-ensure-session 'CIDER)
986995
(sesman-current-session 'CIDER)))))))
987996
(or (seq-filter (lambda (b)
988-
(cider--match-repl-type type b))
997+
(unless
998+
(cider-cljs-pending-p b)
999+
(cider--match-repl-type type b)))
9891000
repls)
9901001
(when ensure
9911002
(cider--no-repls-user-error type)))))

cider-repl.el

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ This cache is stored in the connection buffer.")
224224
(nrepl-dbind-response response (repl-type changed-namespaces)
225225
(when (and repl-type cider-repl-auto-detect-type)
226226
(cider-set-repl-type repl-type))
227+
(when (string= repl-type 'cljs)
228+
(setf cider-cljs-repl-pending nil))
227229
(unless (nrepl-dict-empty-p changed-namespaces)
228230
(setq cider-repl-ns-cache (nrepl-dict-merge cider-repl-ns-cache changed-namespaces))
229231
(dolist (b (buffer-list))

cider.el

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,8 @@ server buffer, in which case a new session for that server is created."
12581258
(cider--update-cljs-type)
12591259
(cider--update-cljs-init-function)
12601260
(plist-put :session-name ses-name)
1261-
(plist-put :repl-type 'pending-cljs)))))
1261+
(plist-put :repl-type 'cljs)
1262+
(plist-put :cider-cljs-repl-pending t)))))
12621263

12631264
;;;###autoload
12641265
(defun cider-connect-clj (&optional params)
@@ -1292,7 +1293,8 @@ parameters regardless of their supplied or default values."
12921293
(cider--update-cljs-type)
12931294
(cider--update-cljs-init-function)
12941295
(plist-put :session-name nil)
1295-
(plist-put :repl-type 'pending-cljs))))
1296+
(plist-put :repl-type 'cljs)
1297+
(plist-put :cider-cljs-repl-pending t))))
12961298

12971299
;;;###autoload
12981300
(defun cider-connect-clj&cljs (params &optional soft-cljs-start)

0 commit comments

Comments
 (0)