Skip to content

Commit 7008a33

Browse files
alexander-yakushevbbatsov
authored andcommitted
[inspector] Fix erratic behavior when multiple REPLs are connected
1 parent baa0430 commit 7008a33

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
* Fix jack-in from inside of remote buffers.
1212
* [#2408](https://github.com/clojure-emacs/cider/issues/2408): Auto-link to sesman session on `cider-find-var`.
13+
* [#2454](https://github.com/clojure-emacs/cider/pull/2454): Fix erratic inspector behavior when multiple REPLs are connected
1314

1415
## 0.18.0 (2018-09-02)
1516

cider-inspector.el

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ This is used as an alternative to the built-in `last-command'. Whenever we
134134
invoke any command through \\[execute-extended-command] and its variants,
135135
the value of `last-command' is not set to the command it invokes.")
136136

137+
(defvar cider-inspector--current-repl nil
138+
"Contains the reference to the REPL where inspector was last invoked from.
139+
This is needed for internal inspector buffer operations (push,
140+
pop) to execute against the correct REPL session.")
141+
137142
;; Operations
138143
;;;###autoload
139144
(defun cider-inspect-expr (expr ns)
@@ -142,6 +147,7 @@ Interactively, EXPR is read from the minibuffer, and NS the
142147
current buffer's namespace."
143148
(interactive (list (cider-read-from-minibuffer "Inspect expression: " (cider-sexp-at-point))
144149
(cider-current-ns)))
150+
(setq cider-inspector--current-repl (cider-current-repl))
145151
(when-let* ((value (cider-sync-request:inspect-expr expr ns (or cider-inspector-page-size 32))))
146152
(cider-inspector--render-value value)))
147153

@@ -197,39 +203,39 @@ Current page will be reset to zero."
197203
(defun cider-sync-request:inspect-pop ()
198204
"Move one level up in the inspector stack."
199205
(thread-first '("op" "inspect-pop")
200-
(cider-nrepl-send-sync-request)
206+
(cider-nrepl-send-sync-request cider-inspector--current-repl)
201207
(nrepl-dict-get "value")))
202208

203209
(defun cider-sync-request:inspect-push (idx)
204210
"Inspect the inside value specified by IDX."
205211
(thread-first `("op" "inspect-push"
206212
"idx" ,idx)
207-
(cider-nrepl-send-sync-request)
213+
(cider-nrepl-send-sync-request cider-inspector--current-repl)
208214
(nrepl-dict-get "value")))
209215

210216
(defun cider-sync-request:inspect-refresh ()
211217
"Re-render the currently inspected value."
212218
(thread-first '("op" "inspect-refresh")
213-
(cider-nrepl-send-sync-request)
219+
(cider-nrepl-send-sync-request cider-inspector--current-repl)
214220
(nrepl-dict-get "value")))
215221

216222
(defun cider-sync-request:inspect-next-page ()
217223
"Jump to the next page in paginated collection view."
218224
(thread-first '("op" "inspect-next-page")
219-
(cider-nrepl-send-sync-request)
225+
(cider-nrepl-send-sync-request cider-inspector--current-repl)
220226
(nrepl-dict-get "value")))
221227

222228
(defun cider-sync-request:inspect-prev-page ()
223229
"Jump to the previous page in paginated collection view."
224230
(thread-first '("op" "inspect-prev-page")
225-
(cider-nrepl-send-sync-request)
231+
(cider-nrepl-send-sync-request cider-inspector--current-repl)
226232
(nrepl-dict-get "value")))
227233

228234
(defun cider-sync-request:inspect-set-page-size (page-size)
229235
"Set the page size in paginated view to PAGE-SIZE."
230236
(thread-first `("op" "inspect-set-page-size"
231237
"page-size" ,page-size)
232-
(cider-nrepl-send-sync-request)
238+
(cider-nrepl-send-sync-request cider-inspector--current-repl)
233239
(nrepl-dict-get "value")))
234240

235241
(defun cider-sync-request:inspect-expr (expr ns page-size)
@@ -238,7 +244,7 @@ Set the page size in paginated view to PAGE-SIZE."
238244
(thread-first (append (nrepl--eval-request expr ns)
239245
`("inspect" "true"
240246
"page-size" ,page-size))
241-
(cider-nrepl-send-sync-request)
247+
(cider-nrepl-send-sync-request cider-inspector--current-repl)
242248
(nrepl-dict-get "value")))
243249

244250
;; Render Inspector from Structured Values

0 commit comments

Comments
 (0)