summaryrefslogtreecommitdiffstats
path: root/src/repl/init.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-10-30 13:36:08 +0800
committerGitHub <noreply@github.com>2023-10-30 13:36:08 +0800
commitba3cc4f15dd4b7457bbcacc64fcdbdbb0362d473 (patch)
tree0689264c52b226c9fe88b1fb6730715a74b5a2a0 /src/repl/init.rs
parent2f9121e515150981ac061389656c33eea577c336 (diff)
downloadaichat-ba3cc4f15dd4b7457bbcacc64fcdbdbb0362d473.tar.gz
feat: deprecate history file (#179)
Diffstat (limited to 'src/repl/init.rs')
-rw-r--r--src/repl/init.rs22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/repl/init.rs b/src/repl/init.rs
index 60fce00..420f596 100644
--- a/src/repl/init.rs
+++ b/src/repl/init.rs
@@ -2,13 +2,13 @@ use super::{
highlighter::ReplHighlighter, prompt::ReplPrompt, validator::ReplValidator, REPL_COMMANDS,
};
-use crate::config::{Config, SharedConfig};
+use crate::config::SharedConfig;
-use anyhow::{Context, Result};
+use anyhow::Result;
use reedline::{
default_emacs_keybindings, default_vi_insert_keybindings, default_vi_normal_keybindings,
- ColumnarMenu, DefaultCompleter, EditMode, Emacs, FileBackedHistory, KeyCode, KeyModifiers,
- Keybindings, Reedline, ReedlineEvent, ReedlineMenu, Vi,
+ ColumnarMenu, DefaultCompleter, EditMode, Emacs, KeyCode, KeyModifiers, Keybindings, Reedline,
+ ReedlineEvent, ReedlineMenu, Vi,
};
const MENU_NAME: &str = "completion_menu";
@@ -27,7 +27,6 @@ impl Repl {
let completer = Self::create_completer(&config, &commands);
let highlighter = ReplHighlighter::new(config.clone(), commands);
- let history = Self::create_history()?;
let menu = Self::create_menu();
let edit_mode: Box<dyn EditMode> = if config.read().keybindings.is_vi() {
let mut normal_keybindings = default_vi_normal_keybindings();
@@ -43,7 +42,6 @@ impl Repl {
let mut editor = Reedline::create()
.with_completer(Box::new(completer))
.with_highlighter(Box::new(highlighter))
- .with_history(history)
.with_menu(menu)
.with_edit_mode(edit_mode)
.with_quick_completions(true)
@@ -75,11 +73,6 @@ impl Repl {
);
keybindings.add_binding(
KeyModifiers::CONTROL,
- KeyCode::Char('l'),
- ReedlineEvent::ExecuteHostCommand(".clear screen".into()),
- );
- keybindings.add_binding(
- KeyModifiers::CONTROL,
KeyCode::Char('s'),
ReedlineEvent::Submit,
);
@@ -89,11 +82,4 @@ impl Repl {
let completion_menu = ColumnarMenu::default().with_name(MENU_NAME);
ReedlineMenu::EngineCompleter(Box::new(completion_menu))
}
-
- fn create_history() -> Result<Box<FileBackedHistory>> {
- Ok(Box::new(
- FileBackedHistory::with_file(1000, Config::history_file()?)
- .with_context(|| "Failed to setup history file")?,
- ))
- }
}