diff options
| author | Krut Patel <kroot.patel@gmail.com> | 2023-03-22 21:46:59 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-22 16:16:59 +0000 |
| commit | 378be6b790c3d504c8d7d873ce035daf926e98ed (patch) | |
| tree | 7e7dd194b2fc033faf251582795dff3fb2363d07 /atuin-client/src/settings.rs | |
| parent | Fix skim search (#795) (diff) | |
| download | atuin-378be6b790c3d504c8d7d873ce035daf926e98ed.zip | |
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/src/settings.rs')
| -rw-r--r-- | atuin-client/src/settings.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs index de9bd640..bbbd78ee 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")] |
