Skip to content
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

Fix erratic inspector behavior when multiple REPLs are connected #2454

Merged
merged 1 commit into from
Sep 17, 2018

Conversation

alexander-yakushev
Copy link
Member

Whenever you have more than one connected REPL, and you use the inspector in one of them, the initial value is displayed correctly, but the subsequent actions (push, pop, change page) show something completely off.

Turns out, the inspector buffer does not know the correct REPL where it was initiated from, so (cider-current-repl) can return a different REPL where the inspector middleware, obviously, doesn't match.

I've been suffering from this problem for quite a while, but only now got annoyed enough to tackle it. I don't know if this is the best solution; but since the current inspector does not allow multiple concurrent inspections for different REPLs, this should work.

@bbatsov
Copy link
Member

bbatsov commented Sep 17, 2018

Seems like a reasonable approach to me. Another would be to link the inspector buffer to the current sesman session when it's created I guess. That should ensure cider-current-repl behaves consistently IMO.

@vspinu Any thoughts from you?

@alexander-yakushev
Copy link
Member Author

I originally thought to do that, but if I understand the current implementation correctly, the inspector buffer is recreated on each inspect. So there are no per-sesion inspector buffers that we can attach the session to. Not sure if we need them either.

@@ -134,6 +134,11 @@ This is used as an alternative to the built-in `last-command'. Whenever we
invoke any command through \\[execute-extended-command] and its variants,
the value of `last-command' is not set to the command it invokes.")

(defvar cider-inspector--current-repl nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should should probably be a buffer-local variable for the inspector buffers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong, but the inspector buffer is not retained between actions. At least, when I try to change a buffer-local variable, it is set back to nil once I do push/pop/whatever.

Copy link
Member

@bbatsov bbatsov Sep 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, well, this part of the codebase is pretty bad and needs a general cleanup. :-) I keep forgetting it's "special" compared to the rest of the code. No need for additional changes now, but generally we should be reusing the buffer most of the time instead of re-creating it all the time.

@bbatsov
Copy link
Member

bbatsov commented Sep 17, 2018

Yeah, that's a good point as well. I've added one small inline remark. You should also mention this bugfix in the changelog.

@vspinu
Copy link
Contributor

vspinu commented Sep 17, 2018

This looks like the right approach to me as well. If I understand correctly inspector is really attached to a single connection and not a session.

There is also a possibility that the REPL is killed in the meanwhile and I don't think there is a provision to kill the inspector with it. A more generic cider--current-repl might work better in the long run; I bet there must be other similar cases. Then we could clean such repl-dependent buffers when the repl is killed.

@bbatsov bbatsov merged commit 7008a33 into master Sep 17, 2018
@bbatsov bbatsov deleted the inspector-multi-session branch September 17, 2018 17:46
@alexander-yakushev
Copy link
Member Author

Thank you!

@alexander-yakushev
Copy link
Member Author

alexander-yakushev commented Sep 17, 2018

Double-checked the snapshot from MELPA just in case – it works 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants