Add inspect-print-current-value op#933
Conversation
5285bcb to
9bed8e7
Compare
|
I can't say I immediately understand the usecase, to be honest.
|
|
@alexander-yakushev Have you seen the screenshot and my explanation here: clojure-emacs/cider#3810 ? It is not printing to stdout, it opens the value in a popup buffer, like That said, let's see where we land with the pretty mode before continuing with this. |
793868d to
264da40
Compare
|
The jdk8 test is failing because of this: I think it's a flaky test, that I have seen failing before. |
|
One question on my mind is whether we need a dedicate op to print the inspector value. I was thinking it might also makes sense to have an op that fetches the current inspector value and for it to be printed separately. I guess the current suggestion would be more efficient, but it seems oddly specific to me. |
|
Hi @bbatsov, I think we need one. Initially I had an op that just returned the rendered value as a string. But I changed it because it caused slowness on large data structures and NREPL timeouts. |
|
@bbatsov I understand what you are saying. But what's "fetching the current inspector value"? You can't "return" a value from nrepl server to the client, it has to be printed into a string anyway. |
|
Yeah, yeah. I'm aware of this - that's why I said that probably it wouldn't be particularly efficient, as you'd need to read the printed string and then pretty print the underlying value again. I was just wondering if we can't come up with something more generic for "printing values stored in X, Y, Z", but I haven't given this much thought. I don't have any serious concerns about the current proposal - just thinking in writing. 😀 |
b2c98ea to
adcf3f5
Compare
| (and (= op "eval") inspect) | ||
| (handle-eval-inspect handler msg) | ||
|
|
||
| (and (= op "inspect-print-current-value")) |
There was a problem hiding this comment.
@alexander-yakushev I moved this out of with-safe-transport because I saw an exception in the *nrepl-messages-buffer*, which I think was caused by the new op sending mutiple lines vs the ops in with-safe-transport returing a response value.
I didn't notice this exception before, because from the user's perspective both seemed to work.
With this change I don't see the exeception anymore. Can you double check that this ok?
There was a problem hiding this comment.
Yeah, I think it makes sense. This op is indeed different in this regard. It's fine to leave this as is, just leave a comment why it stands separately.
This PR adds the `inspect-print-current-value` op. It prints the current value of the inspector with the user provided `::print/print-fn` or a default one. It is used by CIDER in the `cider-inspector-print-current-value` command, bound to "P" in the inspector, to print it's current value.
190a16e to
7ed3f5c
Compare
| ;; This is outside of `with-safe-transport` because it streams the pretty | ||
| ;; printed result to the client in multiple messages. It does NOT return any | ||
| ;; value, which is expected by `with-safe-transport`. | ||
| (= op "inspect-print-current-value") |
There was a problem hiding this comment.
@alexander-yakushev Should we prefix this with cider/ from the beginning or leave this to for another day? (e.g. when we add aliases for the all the existing ops)
There was a problem hiding this comment.
I don't mind; might as well add the prefix now indeed. Would you do it, @r0man?
There was a problem hiding this comment.
I would keep it consistent and do it once we decide to rename all. But I can also do this now (we are talking about this op only right?) if you prefer.
This PR adds the
inspect-print-current-valueop. It prints the current value of the inspector with the user provided::print/print-fnor a default one.It is used by CIDER in the
cider-inspector-print-current-valuecommand, bound to "P" in the inspector, to print it's current value. clojure-emacs/cider#3810Before submitting a PR make sure the following things have been done: