From 64c5e854578b04907717b0f6b3e5e5246d6fd236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20=C4=90=E1=BB=A9c=20To=C3=A0n?= <33489972+ndtoan96@users.noreply.github.com> Date: Sun, 14 Apr 2024 22:33:10 +0700 Subject: [PATCH] feat: smart case completion in `cd` paths (#910) Co-authored-by: sxyazi --- yazi-core/src/completion/commands/show.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/yazi-core/src/completion/commands/show.rs b/yazi-core/src/completion/commands/show.rs index b5b61c1f..0ba8a25d 100644 --- a/yazi-core/src/completion/commands/show.rs +++ b/yazi-core/src/completion/commands/show.rs @@ -26,10 +26,12 @@ impl From for Opt { impl Completion { fn match_candidates(word: &str, cache: &[String]) -> Vec { + let smart = word.chars().all(|c| c.is_lowercase()); + let flow = cache.iter().try_fold( (Vec::with_capacity(LIMIT), Vec::with_capacity(LIMIT)), |(mut prefixed, mut fuzzy), s| { - if s.starts_with(word) { + if (smart && s.to_lowercase().starts_with(word)) || (!smart && s.starts_with(word)) { if s != word { prefixed.push(s); if prefixed.len() >= LIMIT {