roc icon indicating copy to clipboard operation
roc copied to clipboard

Ctrl-C should not interrupt the REPL

Open ageron opened this issue 1 year ago • 0 comments

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:

  • Node: standard (meaning Ctrl-C just interrupts the current command and goes to the next line)
  • Julia: standard
  • Haskell: standard
  • Java: standard
  • Ruby: standard (but adds ^C at the end of the command)
  • Swift: standard (but also adds ^C)
  • Python: standard (but adds a line with KeyboardInterrupt)
  • iPython: clears the current command without going to the next line. There's less visual clutter, but you lose whatever you were typing. I'm not a fan. Still better than shutting down.

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.rs

ageron avatar Jul 05 '24 10:07 ageron