[gnome-builder] file-search: ignore whitespace in search query
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] file-search: ignore whitespace in search query
- Date: Mon, 20 Feb 2017 19:51:50 +0000 (UTC)
commit a188ea2f2f8f6beaa3a4509f0fa2eb1b8beab863
Author: Christian Hergert <chergert redhat com>
Date: Mon Feb 20 11:51:39 2017 -0800
file-search: ignore whitespace in search query
If we come across empty space, just ignore it for the file search. It
mostly just gets in the way.
plugins/file-search/gb-file-search-index.c | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/plugins/file-search/gb-file-search-index.c b/plugins/file-search/gb-file-search-index.c
index 86acb8f..de99581 100644
--- a/plugins/file-search/gb-file-search-index.c
+++ b/plugins/file-search/gb-file-search-index.c
@@ -298,6 +298,8 @@ gb_file_search_index_populate (GbFileSearchIndex *self,
{
g_autoptr(GArray) ar = NULL;
g_auto(IdeSearchReducer) reducer = { 0 };
+ g_autoptr(GString) delimited = NULL;
+ const gchar *iter = query;
IdeContext *icontext;
gsize max_matches;
gsize i;
@@ -314,7 +316,19 @@ gb_file_search_index_populate (GbFileSearchIndex *self,
max_matches = ide_search_context_get_max_results (context);
ide_search_reducer_init (&reducer, context, provider, max_matches);
- ar = fuzzy_match (self->fuzzy, query, max_matches);
+ delimited = g_string_new (NULL);
+
+ for (; *iter; iter = g_utf8_next_char (iter))
+ {
+ gunichar ch = g_utf8_get_char (iter);
+
+ if (!g_unichar_isspace (ch))
+ g_string_append_unichar (delimited, ch);
+ }
+
+ g_print ("Searching with: %s\n", delimited->str);
+
+ ar = fuzzy_match (self->fuzzy, delimited->str, max_matches);
for (i = 0; i < ar->len; i++)
{
@@ -327,7 +341,7 @@ gb_file_search_index_populate (GbFileSearchIndex *self,
g_autoptr(GbFileSearchResult) result = NULL;
g_autofree gchar *markup = NULL;
- markup = ide_completion_item_fuzzy_highlight (match->key, query);
+ markup = ide_completion_item_fuzzy_highlight (match->key, delimited->str);
result = g_object_new (GB_TYPE_FILE_SEARCH_RESULT,
"context", icontext,
"provider", provider,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]