Skip to content

Commit f2ab3d3

Browse files
dottedmagbbatsov
authored andcommitted
[Fix #2415] Filter out killed buffers in cider-repls
If a REPL buffer is killed manually it will leak out of `cider-repls` for .cljc files, so make sure `cider-repls` only return live REPL buffers.
1 parent ad932ac commit f2ab3d3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

cider-connection.el

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -662,18 +662,22 @@ session."
662662
type (car (sesman-current-session 'CIDER)))
663663
repl))))
664664

665+
(defun cider--match-repl-type (type buffer)
666+
"Return non-nil if TYPE matches BUFFER's REPL type."
667+
(let ((buffer-repl-type (cider-repl-type buffer)))
668+
(cond ((null buffer-repl-type) nil)
669+
((or (null type) (equal type "multi")) t)
670+
(t (string= type buffer-repl-type)))))
671+
665672
(defun cider-repls (&optional type ensure)
666673
"Return cider REPLs of TYPE from the current session.
667674
If TYPE is nil or \"multi\", return all repls. If ENSURE is non-nil, throw
668675
an error if no linked session exists."
669676
(let ((repls (cdr (if ensure
670677
(sesman-ensure-session 'CIDER)
671678
(sesman-current-session 'CIDER)))))
672-
(if (or (null type) (equal type "multi"))
673-
repls
674-
(seq-filter (lambda (b)
675-
(string= type (cider-repl-type b)))
676-
repls))))
679+
(seq-filter (lambda (b)
680+
(cider--match-repl-type type b)) repls)))
677681

678682
(defun cider-map-repls (which function)
679683
"Call FUNCTION once for each appropriate REPL as indicated by WHICH.

0 commit comments

Comments
 (0)