From 449de70e566f97213fa5d02466334a204fd559ec Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 13 Jun 2022 22:49:55 +0200 Subject: [PATCH] Change ^C to just abort current input Don't exit the program any more. This mirrors what shells do, and is useful for aborting a reverse search or a too broken input. --- src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index a69d279..7f4ebbf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,7 +27,9 @@ fn get_input(rl: &mut Editor<()>) -> Result { line.truncate(line.trim_end().len()); Ok(line) } - Err(ReadlineError::Interrupted) | Err(ReadlineError::Eof) => Ok(":q".to_string()), + // ^C: like in a shell, abort the current input + Err(ReadlineError::Interrupted) => Ok("".to_string()), + Err(ReadlineError::Eof) => Ok(":q".to_string()), Err(e) => Err(e), } }