-
-
Notifications
You must be signed in to change notification settings - Fork 328
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
Ctrl-C should not interrupt the REPL #6870
Comments
Thanks for the thorough investigation of what other repls do here! So it's actually bothered me that in other repls Ctrl-C doesn't exit, especially because if I end up in the repl by mistake, Ctrl-C is my go-to "I don't know how to exit this program but this is the key combination that exits programs" button. It's both standard and frustrating to me, and the standardization of that frustration makes it even worse. 😆 What if we made Ctrl-C cancel the current command if you have something entered, but if you're at a blank prompt (e.g. you press Ctrl-C twice in a row), then it exits? I've definitely used other programs where pressing Ctrl-C twice is necessary to exit the program, which feels both okay here and also something I would naturally try if I were trying to exit the program (namely, pressing Ctrl-C more than once). |
Hi Richard, thanks for your reply.
I believe this is why shells all adopted a different keystroke to exit (Ctrl-D = EOF). That said, I remember being frustrated the first few times I used shells (a few decades ago), because I didn't know how to exit (not the same level of frustration as trying to exit vi, but still not negligible). A simple solution would be to print "Please press Ctrl-D to exit the REPL" if you press Ctrl-C on an empty command. Also note that bash (and other shells) let you change the default behavior if you want: you can tell it to exit on Ctrl-C if you really want to ( |
Mmh, it looks like rustyline just returns an |
I'd use it :) |
I also like the idea proposed by Richard and think we should aim for that behaviour if possible. I don't have a lot of experience with other REPLs, so I like that it is easy to exit the program using ^C, but I guess I didn't know about ^D. |
I'm new to ROC, really enjoying it so far. 👍
However, in ROC's REPL, pressing Ctrl-C shuts down the REPL immediately (at least on MacOS). I lose whatever I was doing.
In pretty much every other REPL I've ever used, Ctrl-C just cancels the command I'm typing (or only interrupts the currently running evaluation). I've tested the following REPLs:
^C
at the end of the command)^C
)KeyboardInterrupt
)ROC's REPL should not shutdown when Ctrl-C is pressed. It should have the "standard" behavior instead, which prevents losing a session by mistake, and makes it more convenient to cancel the current command (in ROC's REPL, you can type Ctrl-A followed by Ctrl-K, but it's neither obvious nor convenient).
If you're okay with that, I'm happy to contribute a fix (but it might take me a while, I just started learning ROC).
Edit: actually, it might be a really simple fix: removing line 96 (
return 1
) in crates/repl_cli/src/lib.rsThe text was updated successfully, but these errors were encountered: