[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 02/02: Sort character matches after substring matches.

noreply at xfce.org noreply at xfce.org
Fri Feb 20 14:34:12 CET 2015


This is an automated email from the git hooks/post-receive script.

gottcode pushed a commit to branch master
in repository panel-plugins/xfce4-whiskermenu-plugin.

commit ff51320d83908dbed0aad9ccd9f47c4fefa2c7f2
Author: Graeme Gott <graeme at gottcode.org>
Date:   Fri Feb 20 08:20:50 2015 -0500

    Sort character matches after substring matches.
---
 panel-plugin/launcher.cpp |    4 ++++
 panel-plugin/query.cpp    |   14 +++++++-------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/panel-plugin/launcher.cpp b/panel-plugin/launcher.cpp
index be92835..7ada6b3 100644
--- a/panel-plugin/launcher.cpp
+++ b/panel-plugin/launcher.cpp
@@ -277,6 +277,10 @@ int Launcher::search(const Query& query)
 	int match = query.match(m_search_name);
 	if (match != G_MAXINT)
 	{
+		if (match > 5)
+		{
+			match += 10;
+		}
 		return match;
 	}
 
diff --git a/panel-plugin/query.cpp b/panel-plugin/query.cpp
index 40cc9c6..3bcbfa0 100644
--- a/panel-plugin/query.cpp
+++ b/panel-plugin/query.cpp
@@ -113,6 +113,12 @@ int Query::match(const std::string& haystack) const
 		}
 	}
 
+	// Check if haystack contains query
+	if (pos != std::string::npos)
+	{
+		return 5;
+	}
+
 	// Check if haystack contains query as characters
 	bool characters_start_words = true;
 	bool start_word = true;
@@ -143,13 +149,7 @@ int Query::match(const std::string& haystack) const
 	int result = INT_MAX;
 	if (*query_string == 0)
 	{
-		result = characters_start_words ? 5 : 7;
-	}
-
-	// Check if haystack contains query
-	if ((result > 5) && (pos != std::string::npos))
-	{
-		result = 6;
+		result = characters_start_words ? 6 : 7;
 	}
 
 	return result;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list