[gtksourceview] Completion: fix the update of an active completion



commit dabc2989c0a68bfa64a822ac5fd30e0fdce46efb
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Mar 16 15:38:47 2013 +0100

    Completion: fix the update of an active completion
    
    The GtkTextIter was not updated, and the providers were not re-selected.

 gtksourceview/gtksourcecompletion.c |   52 ++++++++++++++++++++++++-----------
 1 files changed, 36 insertions(+), 16 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index 34f2572..1c711bb 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -1282,24 +1282,46 @@ start_interactive_completion (GtkSourceCompletion *completion,
                                    (GDestroyNotify)auto_completion_destroy);
 }
 
-static gboolean
-buffer_delete_range_cb (GtkTextBuffer       *buffer,
-                        GtkTextIter         *start,
-                        GtkTextIter         *end,
-                        GtkSourceCompletion *completion)
+static void
+update_active_completion (GtkSourceCompletion *completion,
+                         GtkTextIter         *new_iter)
 {
-       if (completion->priv->context == NULL)
+       GList *selected_providers;
+
+       g_assert (completion->priv->context != NULL);
+       g_assert (gtk_widget_get_visible (GTK_WIDGET (completion->priv->main_window)));
+
+       g_object_set (completion->priv->context,
+                     "iter", new_iter,
+                     NULL);
+
+       selected_providers = select_providers (completion->priv->providers,
+                                              completion->priv->context);
+
+       if (selected_providers != NULL)
        {
-               gtk_source_completion_hide (completion);
+               update_completion (completion,
+                                  selected_providers,
+                                  completion->priv->context);
+
+               g_list_free (selected_providers);
        }
        else
        {
-               update_completion (completion,
-                                  completion->priv->active_providers,
-                                  completion->priv->context);
+               gtk_source_completion_hide (completion);
        }
+}
 
-       return FALSE;
+static void
+buffer_delete_range_cb (GtkTextBuffer       *buffer,
+                        GtkTextIter         *start,
+                        GtkTextIter         *end,
+                        GtkSourceCompletion *completion)
+{
+       if (completion->priv->context != NULL)
+       {
+               update_active_completion (completion, start);
+       }
 }
 
 static void
@@ -1309,15 +1331,13 @@ buffer_insert_text_cb (GtkTextBuffer       *buffer,
                        gint                 len,
                        GtkSourceCompletion *completion)
 {
-       if (completion->priv->context == NULL)
+       if (completion->priv->context != NULL)
        {
-               start_interactive_completion (completion, location);
+               update_active_completion (completion, location);
        }
        else
        {
-               update_completion (completion,
-                                  completion->priv->active_providers,
-                                  completion->priv->context);
+               start_interactive_completion (completion, location);
        }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]