diff options
author | Michael Catanzaro <mcatanzaro@igalia.com> | 2019-05-01 17:37:52 +0000 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@posteo.net> | 2019-05-02 15:40:40 +0000 |
commit | 4eef366f38e071da3f634cd8f0a7d3c284e14c58 (patch) | |
tree | ca0124ccaece1b0428b14b430e8417ac2d391fca | |
parent | ae83ec16c937e218d0bad41b1feeb4fabfe78943 (diff) | |
download | epiphany-4eef366f38e071da3f634cd8f0a7d3c284e14c58.tar.gz |
suggestion-model: fix searching for bookmarks in top bar
Our test to decide whether or not to show a bookmark is not working very
well. Searching for substrings of the bookmark's title doesn't work, for
instance. Let's show the bookmark in the search results if the search is
a substring of the bookmark's title or URL, nice and simple.
https://bugzilla.redhat.com/show_bug.cgi?id=1705029
(cherry picked from commit 4c2b9f774b313e2f163c57a6524fef91a6f46010)
-rw-r--r-- | src/ephy-suggestion-model.c | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/src/ephy-suggestion-model.c b/src/ephy-suggestion-model.c index 0426add80..799ba0fd5 100644 --- a/src/ephy-suggestion-model.c +++ b/src/ephy-suggestion-model.c @@ -33,7 +33,6 @@ struct _EphySuggestionModel { EphyHistoryService *history_service; EphyBookmarksManager *bookmarks_manager; GSequence *items; - gchar **search_terms; GCancellable *icon_cancellable; }; @@ -63,8 +62,6 @@ ephy_suggestion_model_finalize (GObject *object) g_cancellable_cancel (self->icon_cancellable); g_clear_object (&self->icon_cancellable); - g_strfreev (self->search_terms); - G_OBJECT_CLASS (ephy_suggestion_model_parent_class)->finalize (object); } @@ -189,40 +186,13 @@ ephy_suggestion_model_new (EphyHistoryService *history_service, NULL); } -static void -update_search_terms (EphySuggestionModel *self, - const char *text) -{ - g_assert (EPHY_IS_SUGGESTION_MODEL (self)); - - g_strfreev (self->search_terms); - - self->search_terms = g_strsplit (text, " ", -1); -} - static gboolean should_add_bookmark_to_model (EphySuggestionModel *self, const char *search_string, const char *title, const char *location) { - gboolean ret = TRUE; - - if (self->search_terms) { - guint len = g_strv_length (self->search_terms); - guint i; - - for (i = 0; i < len; i++) { - gchar *str = self->search_terms[i]; - - if (!strstr (str, title ? title : "") && !strstr (str, location ? location : "")) { - ret = FALSE; - break; - } - } - } - - return ret; + return strstr (title, search_string) || strstr (location, search_string); } static void @@ -440,8 +410,6 @@ ephy_suggestion_model_query_async (EphySuggestionModel *self, for (guint i = 0; strings[i]; i++) qlist = g_list_append (qlist, g_strdup (strings[i])); - update_search_terms (self, query); - ephy_history_service_find_urls (self->history_service, 0, 0, MAX_COMPLETION_HISTORY_URLS, 0, |