Unable to enter multiline text in the CLI repl
I was told you can press shift+enter to enter a newline in the repl without evaluating, but that doesn't seem to work for me. Using Ununtu through WSL.
[nix-shell:~/roc]$ git rev-parse HEAD
0ae0e689fc14c7831df5f86b0c66a9ec869cbbda
[nix-shell:~/roc]$ cargo run repl
Finished dev [unoptimized + debuginfo] target(s) in 0.18s
Running `target/debug/roc repl`
The rockin’ roc repl
────────────────────────
Enter an expression, or :help, or :exit/:q.
» test : {
── UNFINISHED RECORD TYPE ──────────────────────────────────────────────────────
I am partway through parsing a record type, but I got stuck here:
4│ test : {
^
I was expecting to see a closing curly brace before this, so try
adding a } and see if that helps?
Note: I may be confused by indentation
What you (we) are looking for is Ctrl+v+Ctrl+j. It works pretty well from anywhere in the prompt! (it's the same behavior as a shell like bash or zsh).
I didn't find a way to bind it to Shift+Enter though, but should we?
We could maybe add this hint to the repl doc/tuto, it's very useful and not obvious.
I didn't find a way to bind it to Shift+Enter though, but should we?
Yes, I'd love that :)
I think the best place to mention the hint is in the REPL itself :) I've made #4161 for this.
We currently our able to automatically detect if an expression is complete in most cases and we will create a new line if the user presses Enter on an incomplete expression. That being said, for the particular case that @cjcone mentions at the top of this issue this does not work. I'll update the issue title to reflect this.
As a follow-up, would it be useful to auto-indent, not just for record definitions but also when statements, closures and maybe others?
I checked and we currently manage newlining with the rustyline library, where unfortunately adding tabs after submitting incomplete input (such as with record = {) is not configurable. Any suggestions on how to manage that?
We already use our own fork of rustyline so I think we can just change that code to our liking :)