roc icon indicating copy to clipboard operation
roc copied to clipboard

Unable to enter multiline text in the CLI repl

Open jared-cone opened this issue 3 years ago • 3 comments

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

jared-cone avatar Mar 06 '22 22:03 jared-cone

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.

ghigt avatar Oct 03 '22 11:10 ghigt

I didn't find a way to bind it to Shift+Enter though, but should we?

Yes, I'd love that :)

Anton-4 avatar Oct 03 '22 11:10 Anton-4

I think the best place to mention the hint is in the REPL itself :) I've made #4161 for this.

Anton-4 avatar Oct 03 '22 12:10 Anton-4

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.

Anton-4 avatar Dec 16 '22 18:12 Anton-4

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?

sekerez avatar Sep 17 '23 22:09 sekerez

We already use our own fork of rustyline so I think we can just change that code to our liking :)

Anton-4 avatar Sep 18 '23 12:09 Anton-4