Skip to content

Commit

Permalink
[inspector] Bind inspector buffer to the code buffer where it was tri…
Browse files Browse the repository at this point in the history
…ggered

This fixes `cider-inspector-def-current-val` defining in `user` namespace.
  • Loading branch information
alexander-yakushev committed May 13, 2024
1 parent e8ba817 commit 1f626a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

- [#3626](https://github.com/clojure-emacs/cider/issues/3626): `cider-ns-refresh`: jump to the relevant file/line on errors.
- [#3628](https://github.com/clojure-emacs/cider/issues/3628): `cider-ns-refresh`: summarize errors as an overlay.
- [#3660](https://github.com/clojure-emacs/cider/issues/3660): Fix `cider-inspector-def-current-val` always defining in `user` namespace.
- Bump the injected `enrich-classpath` to [1.19.3](https://github.com/clojure-emacs/enrich-classpath/compare/v1.19.0...v1.19.3).
- Bump the injected nREPL to [1.1.1](https://github.com/nrepl/nrepl/blob/v1.1.1/CHANGELOG.md#111-2024-02-20).
- 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).
Expand Down
38 changes: 20 additions & 18 deletions cider-inspector.el
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ instead of just its \"value\" entry."
(nrepl-dict-get dict-or-value "doc-fragments")))
(block-tags (when v2
(nrepl-dict-get dict-or-value "doc-block-tags-fragments")))
(ns (cider-current-ns))
(font-size (when-let* ((b (get-buffer cider-inspector-buffer))
(variable 'text-scale-mode-amount)
(continue (local-variable-p variable b)))
Expand All @@ -593,24 +594,25 @@ instead of just its \"value\" entry."
:truncate-lines-defined truncate-lines-defined
:truncate-lines-p truncate-lines-p
:fragments fragments
:block-tags block-tags))
(cider-popup-buffer-display cider-inspector-buffer cider-inspector-auto-select-buffer)
(when cider-inspector-fill-frame (delete-other-windows))
(ignore-errors (cider-inspector-next-inspectable-object 1))
(with-current-buffer cider-inspector-buffer
(when (eq cider-inspector-last-command 'cider-inspector-pop)
(setq cider-inspector-last-command nil)
;; Prevents error message being displayed when we try to pop
;; from the top-level of a data structure
(when cider-inspector-location-stack
(goto-char (pop cider-inspector-location-stack))))

(when (eq cider-inspector-last-command 'cider-inspector-prev-page)
(setq cider-inspector-last-command nil)
;; Prevents error message being displayed when we try to
;; go to a prev-page from the first page
(when cider-inspector-page-location-stack
(goto-char (pop cider-inspector-page-location-stack))))))
:block-tags block-tags)
(cider-popup-buffer-display cider-inspector-buffer cider-inspector-auto-select-buffer)
(when cider-inspector-fill-frame (delete-other-windows))
(ignore-errors (cider-inspector-next-inspectable-object 1))
(with-current-buffer cider-inspector-buffer
(cider-set-buffer-ns ns)
(when (eq cider-inspector-last-command 'cider-inspector-pop)
(setq cider-inspector-last-command nil)
;; Prevents error message being displayed when we try to pop
;; from the top-level of a data structure
(when cider-inspector-location-stack
(goto-char (pop cider-inspector-location-stack))))

(when (eq cider-inspector-last-command 'cider-inspector-prev-page)
(setq cider-inspector-last-command nil)
;; Prevents error message being displayed when we try to
;; go to a prev-page from the first page
(when cider-inspector-page-location-stack
(goto-char (pop cider-inspector-page-location-stack)))))))

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

0 comments on commit 1f626a0

Please sign in to comment.