From 574eff0df1aff9bdc6d32939a03312cc08803de3 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Mon, 17 Apr 2023 23:43:05 +0100 Subject: Add --matching-algorithm option. This replaces the --fuzzy-match algorithm. Available choices are normal, prefix and fuzzy. Levenshtein distance was investigated, but it seems pretty rubbish for tofi's use case, where you normally want a good match when you've only typed a small portion of the target string. --- src/input.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/input.c') diff --git a/src/input.c b/src/input.c index 1049fa9..ad89dbd 100644 --- a/src/input.c +++ b/src/input.c @@ -148,12 +148,12 @@ void add_character(struct tofi *tofi, xkb_keycode_t keycode) entry->input_utf8_length += len; if (entry->drun) { - struct string_ref_vec results = desktop_vec_filter(&entry->apps, entry->input_utf8, tofi->fuzzy_match); + struct string_ref_vec results = desktop_vec_filter(&entry->apps, entry->input_utf8, tofi->matching_algorithm); string_ref_vec_destroy(&entry->results); entry->results = results; } else { struct string_ref_vec tmp = entry->results; - entry->results = string_ref_vec_filter(&entry->results, entry->input_utf8, tofi->fuzzy_match); + entry->results = string_ref_vec_filter(&entry->results, entry->input_utf8, tofi->matching_algorithm); string_ref_vec_destroy(&tmp); } @@ -186,9 +186,9 @@ void input_refresh_results(struct tofi *tofi) entry->input_utf8_length = bytes_written; string_ref_vec_destroy(&entry->results); if (entry->drun) { - entry->results = desktop_vec_filter(&entry->apps, entry->input_utf8, tofi->fuzzy_match); + entry->results = desktop_vec_filter(&entry->apps, entry->input_utf8, tofi->matching_algorithm); } else { - entry->results = string_ref_vec_filter(&entry->commands, entry->input_utf8, tofi->fuzzy_match); + entry->results = string_ref_vec_filter(&entry->commands, entry->input_utf8, tofi->matching_algorithm); } reset_selection(tofi); -- cgit v1.2.3