summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-05-04 15:43:34 +0800
committerGitHub <noreply@github.com>2023-05-04 15:43:34 +0800
commit065a32decb3d58004256cb8d99b1b41a1d57446a (patch)
tree047b1fb86a93ad4956f1a10f62fac2547a978d8c /src
parenta7b31d43672e875d8a1af29f5f4e243151bbcd3f (diff)
downloadaichat-065a32decb3d58004256cb8d99b1b41a1d57446a.tar.gz
feat: support backeted paste (#117)
Diffstat (limited to 'src')
-rw-r--r--src/repl/init.rs3
-rw-r--r--src/repl/mod.rs6
2 files changed, 6 insertions, 3 deletions
diff --git a/src/repl/init.rs b/src/repl/init.rs
index c8bb4c3..2ec30bf 100644
--- a/src/repl/init.rs
+++ b/src/repl/init.rs
@@ -30,7 +30,7 @@ impl Repl {
let history = Self::create_history()?;
let menu = Self::create_menu();
let edit_mode = Box::new(Emacs::new(keybindings));
- let editor = Reedline::create()
+ let mut editor = Reedline::create()
.with_completer(Box::new(completer))
.with_highlighter(Box::new(highlighter))
.with_history(history)
@@ -40,6 +40,7 @@ impl Repl {
.with_partial_completions(true)
.with_validator(Box::new(ReplValidator))
.with_ansi_colors(true);
+ editor.enable_bracketed_paste()?;
let prompt = ReplPrompt::new(config);
Ok(Self { editor, prompt })
}
diff --git a/src/repl/mod.rs b/src/repl/mod.rs
index 663decb..facb115 100644
--- a/src/repl/mod.rs
+++ b/src/repl/mod.rs
@@ -98,8 +98,10 @@ impl Repl {
".clear" => match args {
Some("screen") => term::clear_screen(0)?,
Some("history") => {
- let history = Box::new(self.editor.history_mut());
- history.clear().with_context(|| "Failed to clear history")?;
+ self.editor
+ .history_mut()
+ .clear()
+ .with_context(|| "Failed to clear history")?;
print_now!("\n");
}
Some("role") => handler.handle(ReplCmd::ClearRole)?,