-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
refactor(repl): use an inspector session #7763
refactor(repl): use an inspector session #7763
Conversation
11b8f10
to
043ee12
Compare
@@ -1157,6 +1157,7 @@ fn repl_test_function() { | |||
} | |||
|
|||
#[test] | |||
#[ignore] |
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.
Temporarily ignored, editing (e.g multiline) only works with a tty.
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.
Awesome work @caspervonb just a few minor nitpicks, but other than that I think it's landable.
pub struct Repl { | ||
editor: Editor<()>, | ||
history_file: PathBuf, | ||
#[derive(Completer, Helper, Highlighter, Hinter)] |
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.
Does using derive
here actually provide completions/hints/highlights? Or is it just to have default impls?
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.
Just to have default no-op implementations because the Helper
trait requires them all to be implemented.
let is_closing = session | ||
.post_message( | ||
"Runtime.evaluate".to_string(), | ||
Some(json!({ | ||
"expression": "(globalThis.closed)", | ||
"contextId": context_id, | ||
})), | ||
) | ||
.await? | ||
.get("result") | ||
.unwrap() | ||
.get("value") |
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.
👍 nice
if (repl) { | ||
replLoop(); | ||
} |
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.
Nice to see this go
"contextId": context_id, | ||
// TODO(caspervonb) set repl mode to true to enable const redeclarations and top | ||
// level await | ||
"replMode": false, |
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.
It'd be great if we could switch this on before Friday's release
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.
I'll flip it and add tests as soon as this lands.
This used to work, but appears to be broken in this branch:
|
Oops, yeah bit too eager on the wrapping, need to wind it back to just |
Toned it down a bit to match #7591 exactly. |
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.
LGTM, massive work @caspervonb
This reverts commit 4c779b5.
This ports the REPL over to Rust and makes use of an inspector session to run a REPL on top of any isolate which lets make full use of rustylines various things like validators and completors without having to introduce a bunch of hard to test internal ops and glue code. An accidental but good side effect of this is that the multiple line input we previously had is now an editable multi-line input prompt that is correctly stored in the history as a single entry.
This ports the REPL over to Rust and makes use of an inspector session to run a REPL on top of any isolate which lets make full use of rustylines various things like validators and completors without having to introduce a bunch of hard to test internal ops and glue code.
An accidental but good side effect of this is that the multiple line input we previously had is now an editable multi-line input prompt that is correctly stored in the history as a single entry.
We'll also be able to enable top level await via
replMode
in Runtime.evaluate (inspector protocol).