diff options
Diffstat (limited to 'cli/tools/repl')
-rw-r--r-- | cli/tools/repl/mod.rs | 10 |
1 files changed, 8 insertions, 2 deletions
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) => { |