-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
Accept defs in REPL #1262
Accept defs in REPL #1262
Conversation
by parsing the input as part of the validation (on Enter). This is a reliable way to determine if the input so far could become a valid expression with more input lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this is definitely a new record - fastest time between joining the repo to having a first PR up! 🏆
Congrats, and thanks so much for the first contribution! 😃
@@ -71,7 +71,15 @@ impl Validator for InputValidator { | |||
if ctx.input().is_empty() { | |||
Ok(ValidationResult::Incomplete) | |||
} else { | |||
Ok(ValidationResult::Valid(None)) | |||
let arena = bumpalo::Bump::new(); | |||
match roc_parse::test_helpers::parse_expr_with(&arena, ctx.input()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker, but for a future PR, it would be good to extract this into a separate function so we aren't depending on test_helpers
inside production code. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes fair enough! I saw it as part of the public API of the crate, but the name should have hinted not to use it. Maybe we could rename that module, because it seems like a useful utility to have in order to parse without too much setup.
That would be lovely! The way we used to do it (before a rewrite of some combination of the parser and the REPL which lost it) was that when we were in "multiline mode" we would render So today after merging this PR, it looks like this:
...but it would be nice to have it look like this instead:
|
If you're feeling ambitiuous, here's something that we never had before, but which would make it even nicer: after finally accepting the input, "backspace two spaces" to erase the trailing That would make the final output look like this:
So if you'd like to go for a stretch goal, that would be a nice one! |
Were you using the I agree that having a "continuation" prompt to keep alignment is necessary. I have kept the logic that let the user input an empty line though, so you can still do this at the moment: »
x = 5
y = 6
x + y
11 : Num * |
We were rolling our own - in fact, I think adding |
I have had a look at various issues and PRs on I have quickly implemented multiline prompt using it: https://github.com/rtfeldman/roc/tree/basile/multiline-prompt It looks like this:
Unfortunately it has been open for over a year now. Maybe we should mention we're interested. 😄 |
Aha, nice! Honestly, I'd be fine with our using a fork of
It'd be great if it got merged upstream, of course, but I don't know if we've ever bothered to update |
Corresponding issue: #1187
Accept defs in REPL by parsing the input as part of the validation (on Enter). This is a reliable way to determine if the input so far could become a valid expression with more input lines.
Currently no new prompt is presented on input newline. The issue mentions a
…
prompt, is this something I should try to get back?