[gnome-shell] shell-app: Improve prefix matches



commit c427bba9f120aa5881edb4f3faadc6cd3afc8847
Author: Florian MÃllner <fmuellner gnome org>
Date:   Thu Oct 6 00:16:46 2011 +0200

    shell-app: Improve prefix matches
    
    Currently we use a very strict definition of "prefix", where the
    search term has to match at the very beginning of the searched
    criteria (application name, executable name). Use a more liberal
    definition by including matches where the preceding character is
    a space (application name) or hyphen (executable name) as well;
    as many applications use a prefix, this should improve the quality
    of results.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=623372

 src/shell-app.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/src/shell-app.c b/src/shell-app.c
index 1055857..e6e31df 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -1255,15 +1255,18 @@ _shell_app_match_search_terms (ShellApp  *app,
       current_match = MATCH_NONE;
 
       p = strstr (app->casefolded_name, term);
-      if (p == app->casefolded_name)
-        current_match = MATCH_PREFIX;
-      else if (p != NULL)
-        current_match = MATCH_SUBSTRING;
+      if (p != NULL)
+        {
+          if (p == app->casefolded_name || *(p - 1) == ' ')
+            current_match = MATCH_PREFIX;
+          else
+            current_match = MATCH_SUBSTRING;
+        }
 
       p = strstr (app->casefolded_exec, term);
       if (p != NULL)
         {
-          if (p == app->casefolded_exec)
+          if (p == app->casefolded_exec || *(p - 1) == '-')
             current_match = (current_match == MATCH_NONE) ? MATCH_PREFIX
                                                           : MATCH_MULTIPLE_PREFIX;
           else if (current_match < MATCH_PREFIX)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]