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
This commit is contained in:
Florian Müllner 2011-10-06 00:16:46 +02:00
parent da83ad561b
commit c427bba9f1

View File

@ -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)