summaryrefslogtreecommitdiffstats
path: root/atuin-client
diff options
context:
space:
mode:
authorKrut Patel <kroot.patel@gmail.com>2023-03-22 21:46:59 +0530
committerGitHub <noreply@github.com>2023-03-22 16:16:59 +0000
commit378be6b790c3d504c8d7d873ce035daf926e98ed (patch)
tree7e7dd194b2fc033faf251582795dff3fb2363d07 /atuin-client
parentbc06d5f36f1cbc350f6ba8cd51285cfa49122717 (diff)
Allow changing search_mode during interactive search (#586)
* Make search_mode a part of SearchState * Allow changing search mode using ctrl+s * Tweak state reset for switched_search_mode * Improve search_mode display in interactive mode * Incorporate review suggestion * Tweak language * Fix Clippy and format
Diffstat (limited to 'atuin-client')
-rw-r--r--atuin-client/src/settings.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs
index de9bd640b..bbbd78ee1 100644
--- a/atuin-client/src/settings.rs
+++ b/atuin-client/src/settings.rs
@@ -34,6 +34,32 @@ pub enum SearchMode {
Skim,
}
+impl SearchMode {
+ pub fn as_str(&self) -> &'static str {
+ match self {
+ SearchMode::Prefix => "PREFIX",
+ SearchMode::FullText => "FULLTXT",
+ SearchMode::Fuzzy => "FUZZY",
+ SearchMode::Skim => "SKIM",
+ }
+ }
+ pub fn next(&self, settings: &Settings) -> Self {
+ match self {
+ SearchMode::Prefix => SearchMode::FullText,
+ SearchMode::FullText => {
+ // if the user is using skim, we go to skim, otherwise fuzzy.
+ if settings.search_mode == SearchMode::Skim {
+ SearchMode::Skim
+ } else {
+ SearchMode::Fuzzy
+ }
+ }
+ SearchMode::Fuzzy => SearchMode::Prefix,
+ SearchMode::Skim => SearchMode::Prefix,
+ }
+ }
+}
+
#[derive(Clone, Debug, Deserialize, Copy, PartialEq, Eq, ValueEnum)]
pub enum FilterMode {
#[serde(rename = "global")]