Skip to content

Commit b3b9c67

Browse files
glittersharkbbatsov
authored andcommitted
[Fix #2515] Reset the current buffer after display-buffer
If the user has `:select nil` in their popup rules for the Cider REPL buffer, the call to `display-buffer` to display the repl buffer while initializing it will reset the `current-buffer` to the buffer the user ran `jack-in` from, which breaks any successive calls to `cider-current-repl`. Resetting the current buffer back to the original buffer after `display-buffer` is resilient against this config change, without breaking anything else in the case the config is absent.
1 parent cd98bc0 commit b3b9c67

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cider-repl.el

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,15 @@ client process connection. Unless NO-BANNER is non-nil, insert a banner."
315315
(when cider-repl-display-in-current-window
316316
(add-to-list 'same-window-buffer-names (buffer-name buffer)))
317317
(pcase cider-repl-pop-to-buffer-on-connect
318-
(`display-only (display-buffer buffer))
318+
(`display-only
319+
(let ((orig-buffer (current-buffer)))
320+
(display-buffer buffer)
321+
;; User popup-rules (specifically `:select nil') can cause the call to
322+
;; `display-buffer' to reset the current Emacs buffer to the clj/cljs
323+
;; buffer that the user ran `jack-in' from - we need the current-buffer
324+
;; to be the repl to initialize, so reset it back here to be resilient
325+
;; against user config
326+
(set-buffer orig-buffer)))
319327
((pred identity) (pop-to-buffer buffer)))
320328
(cider-repl-set-initial-ns buffer)
321329
(cider-repl-require-repl-utils)

0 commit comments

Comments
 (0)