feat(tui): Make search case insensitive by default

This commit is contained in:
Patrick Auernig 2024-12-06 21:19:19 +01:00
parent e7bb664cc2
commit 4691dd05d1

View File

@ -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;