clojure-emacs / orchard

A fertile ground for Clojure tooling
Eclipse Public License 1.0
326 stars 54 forks source link

[inspect] Extract inspect-value into a separate printer implementation #241

Closed alexander-yakushev closed 7 months ago

alexander-yakushev commented 7 months ago

Before submitting a PR make sure the following things have been done:

Thanks!

vemv commented 7 months ago

Seems like a good batch of refinements!

Probably the best 'review' I can provide is suggesting that you make install Orchard and then cider-nrepl for a few days - good way to catch anything that might slip by

alexander-yakushev commented 7 months ago

Change of plans.

orchard.inspect/inspect-value is basically a custom value-printing implementation (akin to print-method). It deserves its own place to live, and I have a long-overdue wish to use it in the CIDER debugger as well.

The extracted printer contains the previous performance improvements and new truncation logic. Now it supports:

@vemv The inspector has a pretty good test coverage, so I'm quite optimistic about the changes. Something might change visually but not structurally. Anyway, I would appreciate even a brief review.

alexander-yakushev commented 7 months ago

Extra questions to consider:

vemv commented 7 months ago

I'd say that by default, on an average monitor we should strive to show one line of text at most - or maybe a handful, IDK.

The reason being, such large k-v entries can easily bury other k-v entries.

User can always drill deeper into the data if they need more detail.

(For clarity - before this PR the behavior doesn't seem ideal to me at all)

Perhaps we can leave this aspect essentially unaltered in this PR? I'm not a fan of big PRs anyway.

alexander-yakushev commented 7 months ago

Perhaps we can leave this aspect essentially unaltered in this PR? I'm not a fan of big PRs anyway.

Do you mean disabling long printed value truncation for now?

vemv commented 7 months ago

I'd simply try to keep behavior as close to the current one as possible.

But we can certainly try to refine it afterwards.

alexander-yakushev commented 7 months ago

FYI, the current behavior is this:).

image

But if you want to do this in two-step, first merge all the necessary foundation and second change the user experience, then I'm fine with that.

vemv commented 7 months ago

I've never gotten a SO in practice.

alexander-yakushev commented 7 months ago

It happens sometimes when you work with Java object hierarchies.

alexander-yakushev commented 7 months ago

Regarding why I want this for the debugger:

Around 40% of the time when I use CIDER debugger, I need to perform an extra dance to avoid the step debugger landing on a piece of data that is big (say, ~50-100Mb) because it tries rendering it which hurts both Clojure and Emacs side of the debugger. By unifying the printers that Inspector and Debugger use, and by constraining how much work they do when displaying values, we can greatly improve the UX.

alexander-yakushev commented 7 months ago

Here's my proposal to take it piecemeal. First step:

Later, we can think whether changing these defaults is necessary and what are the optimal values.

bbatsov commented 7 months ago

Around 40% of the time when I use CIDER debugger, I need to perform an extra dance to avoid the step debugger landing on a piece of data that is big (say, ~50-100Mb) because it tries rendering it which hurts both Clojure and Emacs side of the debugger. By unifying the printers that Inspector and Debugger use, and by constraining how much work they do when displaying values, we can greatly improve the UX.

I agree.

@alexander-yakushev I'm fine with your piecemeal proposal, although I'd also be OK with making all changes at once. I really doubt this will affect someone negatively.

vemv commented 7 months ago

Great work - thanks!