[gnome-builder/gnome-builder-3-20] fuzzy-search: fix one char needle case
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-20] fuzzy-search: fix one char needle case
- Date: Mon, 23 May 2016 13:23:01 +0000 (UTC)
commit 02e880a12a369b78bc1baa4e27a8a886c1c7cadc
Author: Sebastien Lafargue <slafargue gnome org>
Date: Mon May 23 13:48:07 2016 +0200
fuzzy-search: fix one char needle case
When the needle is one char long,
we need to remove the duplicates
contrib/search/fuzzy.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/contrib/search/fuzzy.c b/contrib/search/fuzzy.c
index 4238155..311aba6 100644
--- a/contrib/search/fuzzy.c
+++ b/contrib/search/fuzzy.c
@@ -460,13 +460,20 @@ fuzzy_match (Fuzzy *fuzzy,
}
else
{
+ guint last_id = G_MAXUINT;
+
for (i = 0; i < root->len; i++)
{
item = &g_array_index (root, FuzzyItem, i);
- match.key = fuzzy_get_string (fuzzy, item->id);
- match.value = g_ptr_array_index (fuzzy->id_to_value, item->id);
- match.score = 0;
- g_array_append_val (matches, match);
+ match.id = GPOINTER_TO_INT (item->id);
+ if (match.id != last_id)
+ {
+ match.key = fuzzy_get_string (fuzzy, item->id);
+ match.value = g_ptr_array_index (fuzzy->id_to_value, item->id);
+ match.score = 0;
+ g_array_append_val (matches, match);
+ last_id = match.id;
+ }
}
goto cleanup;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]