From: Daniel Carl <danielcarl@gmx.de>
Date: Sat, 6 Apr 2013 18:24:25 +0000 (+0200)
Subject: Simplified completion filtering to use the whole search string.
X-Git-Url: https://git.owens.tech/wrapped.html/wrapped.html/git?a=commitdiff_plain;h=4798fb08f07743cef27b770704d8672e35d16518;p=vimb.git

Simplified completion filtering to use the whole search string.

We search the whole given string in the completion items instead of splitting
it into tokens to match them separately.
---

diff --git a/src/completion.c b/src/completion.c
index de6c7ed..7d49641 100644
--- a/src/completion.c
+++ b/src/completion.c
@@ -142,36 +142,16 @@ void completion_clean()
     vb.state.mode &= ~VB_MODE_COMPLETE;
 }
 
-/* TODO remove none matching entries from given source list */
 static GList *filter_list(GList *target, GList *source, Comp_Func func, const char *input)
 {
-    char **token = NULL;
-    gboolean match;
-
-    token = g_strsplit(input, " ", 0);
-
     for (GList *l = source; l; l = l->next) {
         char *data  = l->data;
-        match = false;
-        if (*input == 0) {
-            match = TRUE;
-        } else {
-            for (int i = 0; token[i]; i++) {
-                if (func(data, token[i])) {
-                    match = TRUE;
-                } else {
-                    match = false;
-                    break;
-                }
-            }
-        }
-        if (match) {
+        if (func(data, input)) {
             target = g_list_prepend(target, data);
         }
     }
 
     target = g_list_reverse(target);
-    g_strfreev(token);
 
     return target;
 }