Skip to content

Commit 797b33d

Browse files
azatclaude
andcommitted
Fix fuzzy search (ignore word position)
Fixes: #201 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f44b3c9 commit 797b33d

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/utils.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,26 @@ where
4545
view.clear();
4646

4747
let matcher = SkimMatcherV2::default();
48+
let query_words: Vec<&str> = query.split_whitespace().collect();
49+
4850
let mut matches: Vec<(i64, String)> = actions
4951
.iter()
5052
.filter_map(|action| {
5153
let action_name = action.text.to_string();
52-
matcher
53-
.fuzzy_match(&action_name, query)
54-
.map(|score| (score, action_name))
54+
55+
if query_words.is_empty() {
56+
return Some((0, action_name));
57+
}
58+
59+
let mut total_score = 0i64;
60+
for word in &query_words {
61+
match matcher.fuzzy_match(&action_name, word) {
62+
Some(score) => total_score += score,
63+
None => return None,
64+
}
65+
}
66+
67+
Some((total_score, action_name))
5568
})
5669
.collect();
5770

0 commit comments

Comments
 (0)