diff --git a/src/repl/completer.rs b/src/repl/completer.rs index 07710017..12e871a5 100644 --- a/src/repl/completer.rs +++ b/src/repl/completer.rs @@ -1,6 +1,6 @@ use super::{ReplCommand, REPL_COMMANDS}; -use crate::config::GlobalConfig; +use crate::{config::GlobalConfig, utils::fuzzy_match}; use reedline::{Completer, Span, Suggestion}; use std::collections::HashMap; @@ -42,7 +42,10 @@ impl Completer for ReplCompleter { .map(|(v, _)| *v) .collect::>() .join(" "); - cmd.name.starts_with(&line) && cmd.name != ".set" + if line == "." { + return true; + } + line.starts_with(&cmd.name[..2]) && fuzzy_match(cmd.name, &line) }) .collect(); diff --git a/src/repl/mod.rs b/src/repl/mod.rs index 735ad256..6b026b5b 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -162,9 +162,9 @@ lazy_static::lazy_static! { "Regenerate the last response", AssertState::pass() ), + ReplCommand::new(".copy", "Copy the last response", AssertState::pass()), ReplCommand::new(".set", "Adjust runtime configuration", AssertState::pass()), ReplCommand::new(".delete", "Delete roles/sessions/RAGs/agents", AssertState::pass()), - ReplCommand::new(".copy", "Copy the last response", AssertState::pass()), ReplCommand::new(".exit", "Exit the REPL", AssertState::pass()), ]; static ref COMMAND_RE: Regex = Regex::new(r"^\s*(\.\S*)\s*").unwrap();