Skip to content

Commit b421bbb

Browse files
[inspector] Bind inspector buffer to the code buffer where it was triggered
This fixes `cider-inspector-def-current-val` defining in `user` namespace.
1 parent e8b9aa6 commit b421bbb

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

CHANGELOG.md

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

1818
- [#3626](https://github.com/clojure-emacs/cider/issues/3626): `cider-ns-refresh`: jump to the relevant file/line on errors.
1919
- [#3628](https://github.com/clojure-emacs/cider/issues/3628): `cider-ns-refresh`: summarize errors as an overlay.
20+
- [#3660](https://github.com/clojure-emacs/cider/issues/3660): Fix `cider-inspector-def-current-val` always defining in `user` namespace.
2021
- Bump the injected `enrich-classpath` to [1.19.3](https://github.com/clojure-emacs/enrich-classpath/compare/v1.19.0...v1.19.3).
2122
- Bump the injected nREPL to [1.1.1](https://github.com/nrepl/nrepl/blob/v1.1.1/CHANGELOG.md#111-2024-02-20).
2223
- Bump the injected `cider-nrepl` to [0.47.0](https://github.com/clojure-emacs/cider-nrepl/blob/v0.47.0/CHANGELOG.md#0470-2024-03-10).

cider-inspector.el

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,8 @@ instead of just its \"value\" entry."
565565
result
566566
(nrepl-dict-get result "value"))))
567567

568+
(declare-function cider-set-buffer-ns "cider-mode")
569+
568570
;; Render Inspector from Structured Values
569571
(defun cider-inspector--render-value (dict-or-value &optional v2)
570572
"Render DICT-OR-VALUE, depending on V2."
@@ -575,6 +577,7 @@ instead of just its \"value\" entry."
575577
(nrepl-dict-get dict-or-value "doc-fragments")))
576578
(block-tags (when v2
577579
(nrepl-dict-get dict-or-value "doc-block-tags-fragments")))
580+
(ns (cider-current-ns))
578581
(font-size (when-let* ((b (get-buffer cider-inspector-buffer))
579582
(variable 'text-scale-mode-amount)
580583
(continue (local-variable-p variable b)))
@@ -593,24 +596,25 @@ instead of just its \"value\" entry."
593596
:truncate-lines-defined truncate-lines-defined
594597
:truncate-lines-p truncate-lines-p
595598
:fragments fragments
596-
:block-tags block-tags))
597-
(cider-popup-buffer-display cider-inspector-buffer cider-inspector-auto-select-buffer)
598-
(when cider-inspector-fill-frame (delete-other-windows))
599-
(ignore-errors (cider-inspector-next-inspectable-object 1))
600-
(with-current-buffer cider-inspector-buffer
601-
(when (eq cider-inspector-last-command 'cider-inspector-pop)
602-
(setq cider-inspector-last-command nil)
603-
;; Prevents error message being displayed when we try to pop
604-
;; from the top-level of a data structure
605-
(when cider-inspector-location-stack
606-
(goto-char (pop cider-inspector-location-stack))))
607-
608-
(when (eq cider-inspector-last-command 'cider-inspector-prev-page)
609-
(setq cider-inspector-last-command nil)
610-
;; Prevents error message being displayed when we try to
611-
;; go to a prev-page from the first page
612-
(when cider-inspector-page-location-stack
613-
(goto-char (pop cider-inspector-page-location-stack))))))
599+
:block-tags block-tags)
600+
(cider-popup-buffer-display cider-inspector-buffer cider-inspector-auto-select-buffer)
601+
(when cider-inspector-fill-frame (delete-other-windows))
602+
(ignore-errors (cider-inspector-next-inspectable-object 1))
603+
(with-current-buffer cider-inspector-buffer
604+
(cider-set-buffer-ns ns)
605+
(when (eq cider-inspector-last-command 'cider-inspector-pop)
606+
(setq cider-inspector-last-command nil)
607+
;; Prevents error message being displayed when we try to pop
608+
;; from the top-level of a data structure
609+
(when cider-inspector-location-stack
610+
(goto-char (pop cider-inspector-location-stack))))
611+
612+
(when (eq cider-inspector-last-command 'cider-inspector-prev-page)
613+
(setq cider-inspector-last-command nil)
614+
;; Prevents error message being displayed when we try to
615+
;; go to a prev-page from the first page
616+
(when cider-inspector-page-location-stack
617+
(goto-char (pop cider-inspector-page-location-stack)))))))
614618

615619
(cl-defun cider-inspector-render (buffer str &key font-size truncate-lines-defined truncate-lines-p fragments block-tags)
616620
"Render STR in BUFFER."

0 commit comments

Comments
 (0)