aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/fuzzy_match
diff options
context:
space:
mode:
authorPascal Kuthe2023-08-30 04:26:21 +0000
committerGitHub2023-08-30 04:26:21 +0000
commit0cb595e226c9970989ee1e680ae6b8011d188cbf (patch)
tree406b31b0343c74f96f9ae80d758f246a04374434 /helix-term/src/ui/fuzzy_match
parent40d7e6c9c85d4f1ce2345f6e9d59fc091243124d (diff)
transition to nucleo for fuzzy matching (#7814)
* transition to nucleo for fuzzy matching * drop flakey test case since the picker streams in results now any test that relies on the picker containing results is potentially flakely * use crates.io version of nucleo * Fix typo in commands.rs Co-authored-by: Skyler Hawthorne <skyler@dead10ck.com> --------- Co-authored-by: Skyler Hawthorne <skyler@dead10ck.com>
Diffstat (limited to 'helix-term/src/ui/fuzzy_match')
-rw-r--r--helix-term/src/ui/fuzzy_match/test.rs47
1 files changed, 0 insertions, 47 deletions
diff --git a/helix-term/src/ui/fuzzy_match/test.rs b/helix-term/src/ui/fuzzy_match/test.rs
deleted file mode 100644
index 5df79eeb..00000000
--- a/helix-term/src/ui/fuzzy_match/test.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-use crate::ui::fuzzy_match::FuzzyQuery;
-use crate::ui::fuzzy_match::Matcher;
-
-fn run_test<'a>(query: &str, items: &'a [&'a str]) -> Vec<String> {
- let query = FuzzyQuery::new(query);
- let matcher = Matcher::default();
- items
- .iter()
- .filter_map(|item| {
- let (_, indices) = query.fuzzy_indices(item, &matcher)?;
- let matched_string = indices
- .iter()
- .map(|&pos| item.chars().nth(pos).unwrap())
- .collect();
- Some(matched_string)
- })
- .collect()
-}
-
-#[test]
-fn match_single_value() {
- let matches = run_test("foo", &["foobar", "foo", "bar"]);
- assert_eq!(matches, &["foo", "foo"])
-}
-
-#[test]
-fn match_multiple_values() {
- let matches = run_test(
- "foo bar",
- &["foo bar", "foo bar", "bar foo", "bar", "foo"],
- );
- assert_eq!(matches, &["foobar", "foobar", "barfoo"])
-}
-
-#[test]
-fn space_escape() {
- let matches = run_test(r"foo\ bar", &["bar foo", "foo bar", "foobar"]);
- assert_eq!(matches, &["foo bar"])
-}
-
-#[test]
-fn trim() {
- let matches = run_test(r" foo bar ", &["bar foo", "foo bar", "foobar"]);
- assert_eq!(matches, &["barfoo", "foobar", "foobar"]);
- let matches = run_test(r" foo bar\ ", &["bar foo", "foo bar", "foobar"]);
- assert_eq!(matches, &["bar foo"])
-}