diff --git a/src/tui.rs b/src/tui.rs index c0dc408..e660142 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -248,13 +248,25 @@ fn fuzzy_search(search: &str, text: &str) -> Option<Vec<usize>> { let mut found_indices = Vec::new(); let mut start_idx = 0; - for ch in search.chars() { + let mut case_sensitive = false; + + for (ch_idx, ch) in search.char_indices() { + if ch_idx == 0 { + case_sensitive = ch.is_uppercase(); + } + let remaining = &text[start_idx..]; let mut found = false; for (byte_idx, txt_ch) in remaining.char_indices() { - if ch == txt_ch { + let matching = if case_sensitive { + ch == txt_ch + } else { + ch.to_lowercase().cmp(txt_ch.to_lowercase()).is_eq() + }; + + if matching { found_indices.push(start_idx + byte_idx); start_idx += byte_idx + txt_ch.len_utf8(); found = true;