-
-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid setting the repl type on each and every nRepl message #2316
Conversation
I think this is some kind of legacy code which no longer serves its purpose. AFAIC judge, It doesn't make much sense to allow nrepl to change repl's type. |
@vspinu Actually it's not legacy at all, it's just not working quite right presently. After each eval operation we try to infer if the user didn't do something that would change the REPL type (which we can't really know without tracking it somehow). That allows for the REPL type to be auto-adjusted when needed - e.g. after The relevant code is here https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/track_state.clj#L172 Clearly the code doesn't work properly, which is a the root cause of this problem. This doesn't invalidate the need for this, though. Also - in general we should enhance describe-session to show the repl-type as well, as this would simplify setting the type on connect. Right now even with this middleware the repl type might be incorrect until the first eval message. |
@@ -233,8 +233,6 @@ via `cider-current-connection'.") | |||
(with-demoted-errors "Error in `cider-repl--state-handler': %s" | |||
(when (member "state" (nrepl-dict-get response "status")) | |||
(nrepl-dbind-response response (repl-type changed-namespaces) | |||
(when repl-type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the right (temporary) solution would be to just make this configurable. Something like "cider-auto-track-repl-type". Or figure out why the cljs env check is failing in some cases.
You likely just have to take a look at |
Forgot about that. Indeed, should have been obvious - cljs environments work by "upgrading" the connection.
To avoid such confusion, cider-create-repl should not set repl-type then. The only source of the type change should be the state-change callback. Note also that |
Thanks these are all great pointers. Now I understand how things work a bit more and can debug. I like the idea of the auto custom though, sometimes you really want to get it to work without exploring why it is not working. Workaround I know...but practical. |
Ideally yes.
An oversight of mine. Thanks for tackling it.
That's a fair point. I'm OK with adding a workaround, but I'd rather wait to see what @vspinu is going to come up with first. |
Ok let's wait for it then, I am ok with having this in my fork for now. |
OK, now that the connection changes are in we can add the config for this. |
I don't know why yet but this seems to work fine now. Closing until further investigation |
This PR has been opened mainly to discuss about this behavior.
When these two lines are in, the
cider-repl-type
variable is always set towhat is coming to nRepl - we trust that nRepl knows if it is in a cljs rather
then a clj REPL.
This seems not to be that true, according to my tests with a
shadow-cljs
REPL:This is not what I would expect. To be honest I haven't tried other repls, but
I will.
In the meantime, any thoughts?