[gnome-builder] GbGitSearchProvider: ignore spaces
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] GbGitSearchProvider: ignore spaces
- Date: Wed, 17 Dec 2014 10:48:13 +0000 (UTC)
commit fb9af5a77d1bbc2de5cb18a9f79391eb27f5a476
Author: Christian Hergert <christian hergert me>
Date: Mon Dec 15 16:57:49 2014 -0800
GbGitSearchProvider: ignore spaces
src/git/gb-git-search-provider.c | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/src/git/gb-git-search-provider.c b/src/git/gb-git-search-provider.c
index e66b5b2..e75e6a8 100644
--- a/src/git/gb-git-search-provider.c
+++ b/src/git/gb-git-search-provider.c
@@ -171,6 +171,22 @@ cleanup:
EXIT;
}
+static gchar *
+remove_spaces (const gchar *text)
+{
+ GString *str = g_string_new (NULL);
+
+ for (; *text; text = g_utf8_next_char (text))
+ {
+ gunichar ch = g_utf8_get_char (text);
+
+ if (ch != ' ')
+ g_string_append_unichar (str, ch);
+ }
+
+ return g_string_free (str, FALSE);
+}
+
static void
gb_git_search_provider_populate (GbSearchProvider *provider,
GbSearchContext *context,
@@ -186,11 +202,13 @@ gb_git_search_provider_populate (GbSearchProvider *provider,
if (self->priv->file_index)
{
const gchar *search_text;
+ gchar *delimited;
GArray *matches;
guint i;
search_text = gb_search_context_get_search_text (context);
- matches = fuzzy_match (self->priv->file_index, search_text,
+ delimited = remove_spaces (search_text);
+ matches = fuzzy_match (self->priv->file_index, delimited,
GB_GIT_SEARCH_PROVIDER_MAX_MATCHES);
for (i = 0; i < matches->len; i++)
@@ -210,7 +228,9 @@ gb_git_search_provider_populate (GbSearchProvider *provider,
list = g_list_reverse (list);
gb_search_context_add_results (context, provider, list, TRUE);
+
g_array_unref (matches);
+ g_free (delimited);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]