mirror of
https://github.com/atuinsh/atuin.git
synced 2025-06-24 20:01:36 +02:00
feat: change fulltext to do multi substring match (#1660)
This commit is contained in:
parent
38dfaabf10
commit
2a65f89cd5
@ -432,7 +432,6 @@ impl Database for Sqlite {
|
|||||||
|
|
||||||
match search_mode {
|
match search_mode {
|
||||||
SearchMode::Prefix => sql.and_where_like_left("command", query),
|
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!
|
// don't recompile the regex on successive calls!
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
@ -453,6 +452,7 @@ impl Database for Sqlite {
|
|||||||
None => (false, query_part),
|
None => (false, query_part),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[allow(clippy::if_same_then_else)]
|
||||||
let param = if query_part == "|" {
|
let param = if query_part == "|" {
|
||||||
if !is_or {
|
if !is_or {
|
||||||
is_or = true;
|
is_or = true;
|
||||||
@ -468,6 +468,8 @@ impl Database for Sqlite {
|
|||||||
format!("{glob}{term}{glob}")
|
format!("{glob}{term}{glob}")
|
||||||
} else if is_inverse {
|
} else if is_inverse {
|
||||||
format!("{glob}{query_part}{glob}")
|
format!("{glob}{query_part}{glob}")
|
||||||
|
} else if search_mode == SearchMode::FullText {
|
||||||
|
format!("{glob}{query_part}{glob}")
|
||||||
} else {
|
} else {
|
||||||
query_part.split("").join(glob)
|
query_part.split("").join(glob)
|
||||||
};
|
};
|
||||||
@ -817,7 +819,10 @@ mod test {
|
|||||||
assert_search_eq(&db, SearchMode::FullText, FilterMode::Global, "/home", 1)
|
assert_search_eq(&db, SearchMode::FullText, FilterMode::Global, "/home", 1)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.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
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user