Skip to content

Commit

Permalink
[inspector] Use inspect-refresh op for dynamic configuration updates
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-yakushev committed Jun 2, 2024
1 parent 5f79b02 commit 8108d23
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Changes

- [#3691](https://github.com/clojure-emacs/cider/pull/3691): Deprecate `cider-sync-request:inspect-set-*` functions in favor of generic `inspect-refresh` op.
- Bump the injected `cider-nrepl` to [0.49.0](https://github.com/clojure-emacs/cider-nrepl/blob/master/CHANGELOG.md#0490-2024-06-02).

### Bugs fixed
Expand Down
40 changes: 21 additions & 19 deletions cider-inspector.el
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,19 @@ See `cider-sync-request:inspect-next-sibling' and `cider-inspector--render-value
(cider-inspector--render-value result 'v2)
(cider-inspector-next-inspectable-object 1))))

(defun cider-inspector--refresh-with-opts (&rest opts)
"Invokes `inspect-refresh' op with supplied extra OPTS.
Re-renders the currently inspected value."
(let ((result (cider-nrepl-send-sync-request `("op" "inspect-refresh" ,@opts)
cider-inspector--current-repl)))
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))

(defun cider-inspector-refresh ()
"Re-render the currently inspected value.
See `cider-sync-request:inspect-refresh' and `cider-inspector--render-value'"
(interactive)
(let ((result (cider-sync-request:inspect-refresh 'v2)))
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))
(cider-inspector--refresh-with-opts))

(defun cider-inspector-next-page ()
"Jump to the next page when inspecting a paginated sequence/map.
Expand All @@ -327,32 +333,24 @@ Does nothing if already on the first page."
Current page will be reset to zero."
(interactive (list (read-number "Page size: " cider-inspector-page-size)))
(let ((result (cider-sync-request:inspect-set-page-size page-size 'v2)))
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))
(cider-inspector--refresh-with-opts "page-size" page-size))

(defun cider-inspector-set-max-atom-length (max-length)
"Set the max length of nested atoms to MAX-LENGTH."
(interactive (list (read-number "Max atom length: " cider-inspector-max-atom-length)))
(let ((result (cider-sync-request:inspect-set-max-atom-length max-length 'v2)))
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))
(cider-inspector--refresh-with-opts "max-atom-length" max-length))

(defun cider-inspector-set-max-coll-size (max-size)
"Set the number of nested collection members to display before truncating.
MAX-SIZE is the new value."
(interactive (list (read-number "Max collection size: " cider-inspector-max-coll-size)))
(let ((result (cider-sync-request:inspect-set-max-coll-size max-size 'v2)))
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))
(cider-inspector--refresh-with-opts "max-coll-size" max-size))

(defun cider-inspector-set-max-nested-depth (max-nested-depth)
"Set the level of nesting for collections to display beflore truncating.
MAX-NESTED-DEPTH is the new value."
(interactive (list (read-number "Max nested depth: " cider-inspector-max-nested-depth)))
(let ((result (cider-sync-request:inspect-set-max-nested-depth max-nested-depth 'v2)))
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))
(cider-inspector--refresh-with-opts "max-nested-depth" max-nested-depth))

(defun cider-inspector-toggle-view-mode ()
"Toggle the view mode of the inspector between normal and object view mode."
Expand Down Expand Up @@ -512,7 +510,8 @@ instead of just its \"value\" entry."
(nrepl-dict-get result "value"))))

(defun cider-sync-request:inspect-set-page-size (page-size &optional v2)
"Set the page size in paginated view to PAGE-SIZE,
"DEPRECATED: use `inspect-refresh' op instead.
Set the page size in paginated view to PAGE-SIZE,
V2 indicates if the entire response should be returned
instead of just its \"value\" entry."
(let ((result (thread-first `("op" "inspect-set-page-size"
Expand All @@ -523,7 +522,8 @@ instead of just its \"value\" entry."
(nrepl-dict-get result "value"))))

(defun cider-sync-request:inspect-set-max-atom-length (max-length &optional v2)
"Set the max length of nested atoms to MAX-LENGTH,
"DEPRECATED: use `inspect-refresh' op instead.
Set the max length of nested atoms to MAX-LENGTH,
V2 indicates if the entire response should be returned
instead of just its \"value\" entry."
(let ((result (thread-first `("op" "inspect-set-max-atom-length"
Expand All @@ -534,7 +534,8 @@ instead of just its \"value\" entry."
(nrepl-dict-get result "value"))))

(defun cider-sync-request:inspect-set-max-coll-size (max-size &optional v2)
"Set the number of nested collection members to display before truncating.
"DEPRECATED: use `inspect-refresh' op instead.
Set the number of nested collection members to display before truncating.
MAX-SIZE is the new value, V2 indicates if the entire response should be returned
instead of just its \"value\" entry."
(let ((result (thread-first `("op" "inspect-set-max-coll-size"
Expand All @@ -545,7 +546,8 @@ instead of just its \"value\" entry."
(nrepl-dict-get result "value"))))

(defun cider-sync-request:inspect-set-max-nested-depth (max-nested-depth &optional v2)
"Set the level of nesting for collections to display before truncating.
"DEPRECATED: use `inspect-refresh' op instead.
Set the level of nesting for collections to display before truncating.
MAX-NESTED-DEPTH is the new value, V2 indicates if the entire response should be returned
instead of just its \"value\" entry."
(let ((result (thread-first `("op" "inspect-set-max-nested-depth"
Expand Down

0 comments on commit 8108d23

Please sign in to comment.