Skip to content

Commit

Permalink
[inspector] Add function and binding for toggling view mode
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-yakushev committed Jun 2, 2024
1 parent b842f0d commit 5f79b02
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### New features

- [#3692](https://github.com/clojure-emacs/cider/pull/3692): Add ability to switch view modes in the ispector (bound to `v`).

### Changes

- Bump the injected `cider-nrepl` to [0.49.0](https://github.com/clojure-emacs/cider-nrepl/blob/master/CHANGELOG.md#0490-2024-06-02).
Expand Down
9 changes: 9 additions & 0 deletions cider-inspector.el
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ by clicking or navigating to them by other means."
(define-key map "a" #'cider-inspector-set-max-atom-length)
(define-key map "c" #'cider-inspector-set-max-coll-size)
(define-key map "C" #'cider-inspector-set-max-nested-depth)
(define-key map "v" #'cider-inspector-toggle-view-mode)
(define-key map "d" #'cider-inspector-def-current-val)
(define-key map "t" #'cider-inspector-tap-current-val)
(define-key map "1" #'cider-inspector-tap-at-point)
Expand Down Expand Up @@ -353,6 +354,14 @@ MAX-NESTED-DEPTH is the new value."
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))

(defun cider-inspector-toggle-view-mode ()
"Toggle the view mode of the inspector between normal and object view mode."
(interactive)
(let ((result (cider-nrepl-send-sync-request `("op" "inspect-toggle-view-mode")
cider-inspector--current-repl)))
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))

(defcustom cider-inspector-preferred-var-names nil
"The preferred var names to be suggested by `cider-inspector-def-current-val'.
Expand Down
4 changes: 4 additions & 0 deletions doc/modules/ROOT/pages/debugging/inspector.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ You'll have access to additional keybindings in the inspector buffer
| `cider-inspector-set-max-atom-length`
| Set a new maximum length above which nested atoms (non-collections) are truncated

| kbd:[v]
| `cider-inspector-toggle-view-mode`
| Switch the rendering of the current value between `:normal` and `:object` view mode. In `:object` mode, any value is rendered as a plain Java object (by displaying its fields) instead of custom rendering rules that the Inspector applies in `:normal` mode.

| kbd:[d]
| `cider-inspector-def-current-val`
| Defines a var in the REPL namespace with current inspector value. If you tend to always choose the same name(s), you may want to set the `cider-inspector-preferred-var-names` customization option.
Expand Down

0 comments on commit 5f79b02

Please sign in to comment.