diff options
| author | sigoden <sigoden@gmail.com> | 2024-04-20 07:53:31 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-20 07:53:31 +0800 |
| commit | 8b806db85791a23f9725adbe09f414464adb6605 (patch) | |
| tree | 2c90336411eb14e674f7a001c2373a49cb3cd77e /src | |
| parent | a9a2caf4aefd5c8d1240ef74f933d4807f0ec6b9 (diff) | |
| download | aichat-8b806db85791a23f9725adbe09f414464adb6605.tar.gz | |
feat: ctrlc won't exit repl and remove `ctrlc_exit` config (#419)
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/mod.rs | 3 | ||||
| -rw-r--r-- | src/repl/mod.rs | 21 |
2 files changed, 3 insertions, 21 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 963ad50..1fe97af 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -63,8 +63,6 @@ pub struct Config { pub wrap: Option<String>, /// Whether wrap code block pub wrap_code: bool, - /// Whether to exit REPL when Ctrl+C is pressed - pub ctrlc_exit: bool, /// Automatically copy the last output to the clipboard pub auto_copy: bool, /// REPL keybindings. (emacs, vi) @@ -114,7 +112,6 @@ impl Default for Config { light_theme: false, wrap: None, wrap_code: false, - ctrlc_exit: false, auto_copy: false, keybindings: Default::default(), prelude: None, diff --git a/src/repl/mod.rs b/src/repl/mod.rs index 4de4251..3f30317 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -102,20 +102,13 @@ impl Repl { pub fn run(&mut self) -> Result<()> { self.banner(); - let mut already_ctrlc = false; - let ctrlc_exit = self.config.read().ctrlc_exit; - loop { if self.abort.aborted_ctrld() { break; } - if self.abort.aborted_ctrlc() && !already_ctrlc { - already_ctrlc = true; - } let sig = self.editor.read_line(&self.prompt); match sig { Ok(Signal::Success(line)) => { - already_ctrlc = false; self.abort.reset(); match self.handle(&line) { Ok(exit) => { @@ -131,15 +124,7 @@ impl Repl { } Ok(Signal::CtrlC) => { self.abort.set_ctrlc(); - if ctrlc_exit { - if already_ctrlc { - break; - } - already_ctrlc = true; - println!("(To exit, press Ctrl+C again or Ctrl+D or type .exit)\n"); - } else { - println!("(To exit, press Ctrl+D or type .exit)\n"); - } + println!("(To exit, press Ctrl+D or type .exit)\n"); } Ok(Signal::CtrlD) => { self.abort.set_ctrld(); @@ -425,8 +410,8 @@ fn dump_repl_help() { r###"{head} Type ::: to begin multi-line editing, type ::: to end it. -Press Ctrl+O to open an buffer editor to modify the current prompt. -Press Ctrl+C to abort aichat, Ctrl+D to exit the REPL"###, +Press Ctrl+O to open an editor to edit line input. +Press Ctrl+C to cancel reply, Ctrl+D to exit REPL"###, ); } |
