diff options
author | δΎδΊ <lilydjwg@gmail.com> | 2024-02-19 19:03:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-19 11:03:09 +0000 |
commit | 2a65f89cd54b8b8187240a1fdc288867b35f6b01 (patch) | |
tree | 3d56ecbc2c1cde353dab106978808b052e5a0ac8 | |
parent | 38dfaabf1034558896efab6f37883eacea271d28 (diff) |
feat: change fulltext to do multi substring match (#1660)
-rw-r--r-- | atuin-client/src/database.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/atuin-client/src/database.rs b/atuin-client/src/database.rs index e67fe06d..572955f8 100644 --- a/atuin-client/src/database.rs +++ b/atuin-client/src/database.rs @@ -432,7 +432,6 @@ impl Database for Sqlite { match search_mode { SearchMode::Prefix => sql.and_where_like_left("command", query), - SearchMode::FullText => sql.and_where_like_any("command", query), _ => { // don't recompile the regex on successive calls! lazy_static! { @@ -453,6 +452,7 @@ impl Database for Sqlite { None => (false, query_part), }; + #[allow(clippy::if_same_then_else)] let param = if query_part == "|" { if !is_or { is_or = true; @@ -468,6 +468,8 @@ impl Database for Sqlite { format!("{glob}{term}{glob}") } else if is_inverse { format!("{glob}{query_part}{glob}") + } else if search_mode == SearchMode::FullText { + format!("{glob}{query_part}{glob}") } else { query_part.split("").join(glob) }; @@ -817,7 +819,10 @@ mod test { assert_search_eq(&db, SearchMode::FullText, FilterMode::Global, "/home", 1) .await .unwrap(); - assert_search_eq(&db, SearchMode::FullText, FilterMode::Global, "ls ", 0) + assert_search_eq(&db, SearchMode::FullText, FilterMode::Global, "ls ho", 1) + .await + .unwrap(); + assert_search_eq(&db, SearchMode::FullText, FilterMode::Global, "hm", 0) .await .unwrap(); } |