[gnome-builder/wip/uajain/word-completion] Minor changes
- From: Umang Jain <uajain src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/uajain/word-completion] Minor changes
- Date: Thu, 24 Aug 2017 22:58:32 +0000 (UTC)
commit db94aedd123a194b42c61204346880442d7d4b5b
Author: Umang Jain <mailumangjain gmail com>
Date: Fri Aug 25 04:27:41 2017 +0530
Minor changes
libide/sourceview/ide-word-completion-provider.c | 48 +++++++++++----------
1 files changed, 25 insertions(+), 23 deletions(-)
---
diff --git a/libide/sourceview/ide-word-completion-provider.c
b/libide/sourceview/ide-word-completion-provider.c
index e7d47f9..1ff80d2 100644
--- a/libide/sourceview/ide-word-completion-provider.c
+++ b/libide/sourceview/ide-word-completion-provider.c
@@ -28,6 +28,7 @@
#include "sourceview/ide-word-completion-item.h"
#include "sourceview/ide-word-completion-results.h"
#include "sourceview/ide-completion-provider.h"
+#include "ide-debug.h"
enum
{
@@ -53,7 +54,7 @@ struct _IdeWordCompletionProviderPrivate
GtkSourceCompletionActivation activation;
GIcon *icon;
GtkTextIter insert_iter;
- gchar *word;
+ gchar *current_word;
gulong cancel_id;
gchar *name;
gint interactive_delay;
@@ -158,8 +159,7 @@ ide_word_completion_provider_get_gicon (GtkSourceCompletionProvider *self)
static void
completion_cleanup (IdeWordCompletionProvider *self)
{
- g_free (self->priv->word);
- self->priv->word = NULL;
+ g_clear_pointer (&self->priv->current_word, g_free);
if (self->priv->context != NULL)
{
@@ -191,48 +191,50 @@ ide_word_completion_provider_populate (GtkSourceCompletionProvider *provider,
GtkSourceCompletionContext *context)
{
IdeWordCompletionProvider *self = IDE_WORD_COMPLETION_PROVIDER (provider);
+ gchar *search_text = NULL;
if (!gtk_source_completion_context_get_iter (context, &self->priv->insert_iter))
{
gtk_source_completion_context_add_proposals (context, provider, NULL, TRUE);
- return;
+ IDE_EXIT;
}
- g_free (self->priv->word);
- self->priv->word = NULL;
-
g_assert (self->priv->search_settings == NULL);
g_assert (self->priv->search_context == NULL);
- self->priv->search_settings = gtk_source_search_settings_new ();
-
- self->priv->search_context = gtk_source_search_context_new (GTK_SOURCE_BUFFER (gtk_text_iter_get_buffer
(&self->priv->insert_iter)),
- self->priv->search_settings);
- self->priv->context = g_object_ref (context);
-
- gtk_source_search_settings_set_regex_enabled (self->priv->search_settings, TRUE);
- gtk_source_search_settings_set_at_word_boundaries (self->priv->search_settings, TRUE);
- gtk_source_search_settings_set_wrap_around (self->priv->search_settings, TRUE);
+ g_clear_pointer (&self->priv->current_word, g_free);
+ self->priv->current_word = ide_completion_provider_context_current_word (context);
+ //TODO : handle "minimum word size"
- self->priv->word = g_strconcat (ide_completion_provider_context_current_word (context),
- "[a-zA-Z0-9_]*",
- NULL);
if (self->priv->results != NULL)
{
- if (ide_completion_results_replay (IDE_COMPLETION_RESULTS (self->priv->results),
ide_completion_provider_context_current_word (context)))
+ if (ide_completion_results_replay (IDE_COMPLETION_RESULTS (self->priv->results),
self->priv->current_word))
{
ide_completion_results_present (IDE_COMPLETION_RESULTS (self->priv->results), provider, context);
- return; //IDE EXIT
+ IDE_EXIT;
}
g_clear_pointer (&self->priv->results, g_object_unref);
}
- gtk_source_search_settings_set_search_text (self->priv->search_settings, self->priv->word);
+ self->priv->search_settings = g_object_new (GTK_SOURCE_TYPE_SEARCH_SETTINGS,
+ "at-word-boundaries", TRUE,
+ "regex-enabled", TRUE,
+ "wrap-around", TRUE,
+ NULL);
+
+
+ self->priv->search_context = gtk_source_search_context_new (GTK_SOURCE_BUFFER (gtk_text_iter_get_buffer
(&self->priv->insert_iter)),
+ self->priv->search_settings);
+ self->priv->context = g_object_ref (context);
+
+ search_text = g_strconcat (self->priv->current_word, "[a-zA-Z0-9_]*", NULL);
+ gtk_source_search_settings_set_search_text (self->priv->search_settings, search_text);
+ g_free (search_text);
self->priv->cancel_id = g_signal_connect_swapped (context, "cancelled", G_CALLBACK
(completion_cancelled_cb), self);
self->priv->wrap_around_flag = FALSE;
- self->priv->results = ide_word_completion_results_new (ide_completion_provider_context_current_word
(context));
+ self->priv->results = ide_word_completion_results_new (self->priv->current_word);
self->priv->all_proposals = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]