[gnome-builder] libide/search: requery search results when truncated
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/search: requery search results when truncated
- Date: Wed, 20 Jul 2022 02:38:03 +0000 (UTC)
commit 954646908086a9770984ef97085d59a9cf8691da
Author: Christian Hergert <chergert redhat com>
Date: Tue Jul 19 19:19:47 2022 -0700
libide/search: requery search results when truncated
If we got a truncated search result, then we should avoid refiltering the
old set and instead query a new result set so that we load potentially
missing search results.
Fixes #1716
src/libide/search/ide-search-engine.c | 5 ++++-
src/libide/search/ide-search-results-private.h | 3 ++-
src/libide/search/ide-search-results.c | 13 ++++++++++++-
3 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/libide/search/ide-search-engine.c b/src/libide/search/ide-search-engine.c
index 94bcc4ef5..9aefa9f44 100644
--- a/src/libide/search/ide-search-engine.c
+++ b/src/libide/search/ide-search-engine.c
@@ -299,6 +299,7 @@ ide_search_engine_search_cb (GObject *object,
{
g_autoptr(GListStore) store = g_list_store_new (G_TYPE_LIST_MODEL);
g_autoptr(GtkFlattenListModel) flatten = gtk_flatten_list_model_new (G_LIST_MODEL (g_object_ref
(store)));
+ gboolean truncated = FALSE;
for (guint i = 0; i < r->sorted->len; i++)
{
@@ -306,10 +307,12 @@ ide_search_engine_search_cb (GObject *object,
if (info->results != NULL)
g_list_store_append (store, info->results);
+
+ truncated |= info->truncated;
}
ide_task_return_pointer (task,
- _ide_search_results_new (G_LIST_MODEL (flatten), r->query),
+ _ide_search_results_new (G_LIST_MODEL (flatten), r->query, truncated),
g_object_unref);
}
}
diff --git a/src/libide/search/ide-search-results-private.h b/src/libide/search/ide-search-results-private.h
index dd19016b9..bbaa3a870 100644
--- a/src/libide/search/ide-search-results-private.h
+++ b/src/libide/search/ide-search-results-private.h
@@ -25,6 +25,7 @@
G_BEGIN_DECLS
IdeSearchResults *_ide_search_results_new (GListModel *model,
- const char *query);
+ const char *query,
+ gboolean truncated);
G_END_DECLS
diff --git a/src/libide/search/ide-search-results.c b/src/libide/search/ide-search-results.c
index 92de91336..a3fdd7676 100644
--- a/src/libide/search/ide-search-results.c
+++ b/src/libide/search/ide-search-results.c
@@ -41,6 +41,9 @@ struct _IdeSearchResults
/* The original query and it's length */
char *query;
gsize query_len;
+
+ /* If the original search set was truncated */
+ guint truncated : 1;
};
static GType
@@ -117,7 +120,8 @@ ide_search_results_filter (gpointer item,
IdeSearchResults *
_ide_search_results_new (GListModel *model,
- const char *query)
+ const char *query,
+ gboolean truncated)
{
IdeSearchResults *self;
@@ -125,6 +129,7 @@ _ide_search_results_new (GListModel *model,
g_return_val_if_fail (query != NULL, NULL);
self = g_object_new (IDE_TYPE_SEARCH_RESULTS, NULL);
+ self->truncated = !!truncated;
self->query = g_strdup (query);
self->query_len = strlen (query);
self->refilter = g_strdup (query);
@@ -153,6 +158,12 @@ ide_search_results_refilter (IdeSearchResults *self,
g_return_val_if_fail (IDE_IS_SEARCH_RESULTS (self), FALSE);
g_return_val_if_fail (query != NULL, FALSE);
+ /* Can't refilter truncated sets, we want a new result set
+ * instead so that we get possibly missing results.
+ */
+ if (self->truncated)
+ IDE_RETURN (FALSE);
+
/* Make sure we have the prefix of the original search */
if (memcmp (self->query, query, self->query_len) != 0)
IDE_RETURN (FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]