implement smart case completion

This commit is contained in:
Nguyen Duc Toan 2024-04-14 13:37:50 +07:00
parent a70374fced
commit 988093b50e
No known key found for this signature in database
GPG key ID: B96F4A160C6B3251

View file

@ -29,7 +29,12 @@ impl Completion {
let flow = cache.iter().try_fold(
(Vec::with_capacity(LIMIT), Vec::with_capacity(LIMIT)),
|(mut prefixed, mut fuzzy), s| {
if s.starts_with(word) {
let start_with_word = if word.chars().any(|c| c.is_uppercase()) {
s.starts_with(word)
} else {
s.to_lowercase().starts_with(word)
};
if start_with_word {
if s != word {
prefixed.push(s);
if prefixed.len() >= LIMIT {