From c0a3b61fb344a5ca86cae1c31d2e42fbe56b6726 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Mon, 16 Jun 2025 10:17:43 +0200 Subject: feat(yt/videos/list): Replace the nucleo matcher with a simple `contains` The matching behaviour was not predictable at all (probably due to a bad config), which than led to using `yt videos ls | grep -i ` instead. --- crates/yt/Cargo.toml | 1 - crates/yt/src/videos/mod.rs | 21 ++++----------------- 2 files changed, 4 insertions(+), 18 deletions(-) (limited to 'crates') diff --git a/crates/yt/Cargo.toml b/crates/yt/Cargo.toml index 6803e68..100eb29 100644 --- a/crates/yt/Cargo.toml +++ b/crates/yt/Cargo.toml @@ -30,7 +30,6 @@ chrono = { version = "0.4.41", features = ["now"] } chrono-humanize = "0.2.3" clap = { version = "4.5.40", features = ["derive"] } futures = "0.3.31" -nucleo-matcher = "0.3.1" owo-colors = "4.2.1" regex = "1.11.1" sqlx = { version = "0.8.6", features = ["runtime-tokio", "sqlite"] } diff --git a/crates/yt/src/videos/mod.rs b/crates/yt/src/videos/mod.rs index e821772..960340b 100644 --- a/crates/yt/src/videos/mod.rs +++ b/crates/yt/src/videos/mod.rs @@ -11,10 +11,6 @@ use anyhow::Result; use futures::{TryStreamExt, stream::FuturesUnordered}; -use nucleo_matcher::{ - Matcher, - pattern::{CaseMatching, Normalization, Pattern}, -}; pub mod display; @@ -46,19 +42,10 @@ pub async fn query(app: &App, limit: Option, search_query: Option .await?; if let Some(query) = search_query { - let mut matcher = Matcher::new(nucleo_matcher::Config::DEFAULT.match_paths()); - - let pattern_matches = Pattern::parse( - &query.replace(' ', "\\ "), - CaseMatching::Ignore, - Normalization::Smart, - ) - .match_list(all_video_strings, &mut matcher); - - pattern_matches - .iter() - .rev() - .for_each(|(val, key)| println!("{val} ({key})")); + all_video_strings + .into_iter() + .filter(|video| video.to_lowercase().contains(&query.to_lowercase())) + .for_each(|video| println!("{video}")); } else { println!("{}", all_video_strings.join("\n")); } -- cgit 1.4.1