diff options
author | Alexander Yakushev <alex@bytopia.org> | 2018-09-16 19:09:38 +0300 |
---|---|---|
committer | Bozhidar Batsov <bozhidar.batsov@gmail.com> | 2018-09-17 20:46:33 +0300 |
commit | 7008a33b3379afb5a7a2c932c813742e0050a90f (patch) | |
tree | b171cf3dd7019f756cb0273ebb9be7415936ec42 | |
parent | baa0430625d486bc4752337716770b979d687a5d (diff) |
[inspector] Fix erratic behavior when multiple REPLs are connected
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | cider-inspector.el | 20 |
2 files changed, 14 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 072bdd35..de016022 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * Fix jack-in from inside of remote buffers. * [#2408](https://github.com/clojure-emacs/cider/issues/2408): Auto-link to sesman session on `cider-find-var`. +* [#2454](https://github.com/clojure-emacs/cider/pull/2454): Fix erratic inspector behavior when multiple REPLs are connected ## 0.18.0 (2018-09-02) diff --git a/cider-inspector.el b/cider-inspector.el index 61d5007d..21c2d987 100644 --- a/cider-inspector.el +++ b/cider-inspector.el @@ -134,6 +134,11 @@ This is used as an alternative to the built-in `last-command'. Whenever we invoke any command through \\[execute-extended-command] and its variants, the value of `last-command' is not set to the command it invokes.") +(defvar cider-inspector--current-repl nil + "Contains the reference to the REPL where inspector was last invoked from. +This is needed for internal inspector buffer operations (push, +pop) to execute against the correct REPL session.") + ;; Operations ;;;###autoload (defun cider-inspect-expr (expr ns) @@ -142,6 +147,7 @@ Interactively, EXPR is read from the minibuffer, and NS the current buffer's namespace." (interactive (list (cider-read-from-minibuffer "Inspect expression: " (cider-sexp-at-point)) (cider-current-ns))) + (setq cider-inspector--current-repl (cider-current-repl)) (when-let* ((value (cider-sync-request:inspect-expr expr ns (or cider-inspector-page-size 32)))) (cider-inspector--render-value value))) @@ -197,39 +203,39 @@ Current page will be reset to zero." (defun cider-sync-request:inspect-pop () "Move one level up in the inspector stack." (thread-first '("op" "inspect-pop") - (cider-nrepl-send-sync-request) + (cider-nrepl-send-sync-request cider-inspector--current-repl) (nrepl-dict-get "value"))) (defun cider-sync-request:inspect-push (idx) "Inspect the inside value specified by IDX." (thread-first `("op" "inspect-push" "idx" ,idx) - (cider-nrepl-send-sync-request) + (cider-nrepl-send-sync-request cider-inspector--current-repl) (nrepl-dict-get "value"))) (defun cider-sync-request:inspect-refresh () "Re-render the currently inspected value." (thread-first '("op" "inspect-refresh") - (cider-nrepl-send-sync-request) + (cider-nrepl-send-sync-request cider-inspector--current-repl) (nrepl-dict-get "value"))) (defun cider-sync-request:inspect-next-page () "Jump to the next page in paginated collection view." (thread-first '("op" "inspect-next-page") - (cider-nrepl-send-sync-request) + (cider-nrepl-send-sync-request cider-inspector--current-repl) (nrepl-dict-get "value"))) (defun cider-sync-request:inspect-prev-page () "Jump to the previous page in paginated collection view." (thread-first '("op" "inspect-prev-page") - (cider-nrepl-send-sync-request) + (cider-nrepl-send-sync-request cider-inspector--current-repl) (nrepl-dict-get "value"))) (defun cider-sync-request:inspect-set-page-size (page-size) "Set the page size in paginated view to PAGE-SIZE." (thread-first `("op" "inspect-set-page-size" "page-size" ,page-size) - (cider-nrepl-send-sync-request) + (cider-nrepl-send-sync-request cider-inspector--current-repl) (nrepl-dict-get "value"))) (defun cider-sync-request:inspect-expr (expr ns page-size) @@ -238,7 +244,7 @@ Set the page size in paginated view to PAGE-SIZE." (thread-first (append (nrepl--eval-request expr ns) `("inspect" "true" "page-size" ,page-size)) - (cider-nrepl-send-sync-request) + (cider-nrepl-send-sync-request cider-inspector--current-repl) (nrepl-dict-get "value"))) ;; Render Inspector from Structured Values |