[epiphany/mcatanzaro/bookmark-search: 6/6] suggestion-model: fix searching for bookmarks in top bar
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/mcatanzaro/bookmark-search: 6/6] suggestion-model: fix searching for bookmarks in top bar
- Date: Thu, 2 May 2019 15:39:57 +0000 (UTC)
commit 4c2b9f774b313e2f163c57a6524fef91a6f46010
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Wed May 1 12:37:52 2019 -0500
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
src/ephy-suggestion-model.c | 34 +---------------------------------
1 file changed, 1 insertion(+), 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]