clojure-emacs / cider-nrepl

A collection of nREPL middleware to enhance Clojure editors with common functionality like definition lookup, code completion, etc.
https://docs.cider.mx/cider-nrepl
670 stars 175 forks source link

[inspect] Use new stack-based view mode #880

Closed alexander-yakushev closed 1 month ago

alexander-yakushev commented 1 month ago

After using the new view-mode functionality locally for some time, I concluded that in 99% of cases you only want to toggle :object view mode for the currently inspected value. When you subsequently click on one of the fields to inspect further, you'd rather see the normal view mode again. So, in my experience, it looked like v, click the field with usually a recognizable data structure, v again to toggle back to normal view mode.

I propose to make this behavior the default one. When the user navigates away from the current view, the view-mode will reset. For that, I've introduced a concept of "transient config values".

In this PR, any action other than toggle-view-mode will reset the view-mode back to :normal. Now that I think of it, some actions make sense to preserve the view mode, e.g. next-prev/sibling (if you are viewing the value in :object view, it's likely you want to see its sibling in that view too). prev/next page don't make sense for object view, so it's whatever there. So, perhaps, the resetting logic should only exist for down/up ops. Maybe maintain it as another stack (this will be neat but require the most work)?

WDYT?

EDIT

It was decided to implement :view-mode switching on the Orchard side and keep a stack of modes for the history of inspected values. That way, when the user downs to another value, the :view-mode is reset to :normal. When they go back up, the :view-mode is restored from the stack.