summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/integration/inspector_tests.rs2
-rw-r--r--cli/tools/repl/mod.rs10
2 files changed, 9 insertions, 3 deletions
diff --git a/cli/tests/integration/inspector_tests.rs b/cli/tests/integration/inspector_tests.rs
index f60e870c6..f18b009da 100644
--- a/cli/tests/integration/inspector_tests.rs
+++ b/cli/tests/integration/inspector_tests.rs
@@ -561,7 +561,7 @@ async fn inspector_runtime_evaluate_does_not_crash() {
assert_eq!(
&stdout_lines.next().unwrap(),
- "exit using ctrl+d or close()"
+ "exit using ctrl+d, ctrl+c, or close()"
);
assert_inspector_messages(
diff --git a/cli/tools/repl/mod.rs b/cli/tools/repl/mod.rs
index 110a89f14..c8efd3d95 100644
--- a/cli/tools/repl/mod.rs
+++ b/cli/tools/repl/mod.rs
@@ -81,6 +81,7 @@ pub async fn run(
) -> Result<i32, AnyError> {
let mut repl_session = ReplSession::initialize(worker).await?;
let mut rustyline_channel = rustyline_channel();
+ let mut should_exit_on_interrupt = false;
let helper = EditorHelper {
context_id: repl_session.context_id,
@@ -118,7 +119,7 @@ pub async fn run(
}
println!("Deno {}", crate::version::deno());
- println!("exit using ctrl+d or close()");
+ println!("exit using ctrl+d, ctrl+c, or close()");
loop {
let line = read_line_and_poll(
@@ -129,6 +130,7 @@ pub async fn run(
.await;
match line {
Ok(line) => {
+ should_exit_on_interrupt = false;
let output = repl_session.evaluate_line_and_get_output(&line).await?;
// We check for close and break here instead of making it a loop condition to get
@@ -142,7 +144,11 @@ pub async fn run(
editor.add_history_entry(line);
}
Err(ReadlineError::Interrupted) => {
- println!("exit using ctrl+d or close()");
+ if should_exit_on_interrupt {
+ break;
+ }
+ should_exit_on_interrupt = true;
+ println!("press ctrl+c again to exit");
continue;
}
Err(ReadlineError::Eof) => {