[gnome-builder] libide/gui: alter search delay by query length
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/gui: alter search delay by query length
- Date: Wed, 20 Jul 2022 02:38:02 +0000 (UTC)
commit 11247032e3c3134be22d30cd04f823e66344cad7
Author: Christian Hergert <chergert redhat com>
Date: Tue Jul 19 18:46:17 2022 -0700
libide/gui: alter search delay by query length
We want to increase the chance that we aren't filtering by a single
character in the result set.
src/libide/gui/ide-search-popover.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/src/libide/gui/ide-search-popover.c b/src/libide/gui/ide-search-popover.c
index 813977d7c..1e53a9cb0 100644
--- a/src/libide/gui/ide-search-popover.c
+++ b/src/libide/gui/ide-search-popover.c
@@ -26,7 +26,9 @@
#include "ide-search-resources.h"
#include "ide-gui-global.h"
-#define SEARCH_DELAY_MSEC 30
+#define LONG_SEARCH_DELAY_MSEC 300
+#define SHORT_SEARCH_DELAY_MSEC 50
+
#define MAX_RESULTS 1000 /* 0 for unlimited */
struct _IdeSearchPopover
@@ -210,20 +212,26 @@ failure:
static void
ide_search_popover_queue_search (IdeSearchPopover *self)
{
+ const char *text;
+ guint delay;
+
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (IDE_IS_SEARCH_POPOVER (self));
- if (self->queued_search == 0)
- {
- guint delay = SEARCH_DELAY_MSEC;
+ g_clear_handle_id (&self->queued_search, g_source_remove);
- if (self->activate_after_search)
- delay = 0;
+ text = gtk_editable_get_text (GTK_EDITABLE (self->entry));
- self->queued_search = g_timeout_add (delay,
- ide_search_popover_search_source_func,
- self);
- }
+ if (self->activate_after_search)
+ delay = 0;
+ else if (strlen (text) < 3)
+ delay = LONG_SEARCH_DELAY_MSEC;
+ else
+ delay = SHORT_SEARCH_DELAY_MSEC;
+
+ self->queued_search = g_timeout_add (delay,
+ ide_search_popover_search_source_func,
+ self);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]