[gnome-builder] fuzzy-search: fix one char needle case



commit be40f9c38518b0d90d890adff43f7c4ba11b5e3b
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]