[gtksourceview] Completion: fix bug when a proposal is hidden



commit 9e082b77ad6500a074758c1a594664f6609aa472
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Jun 12 21:39:07 2013 +0200

    Completion: fix bug when a proposal is hidden
    
    See the comment in the code.

 gtksourceview/gtksourcecompletion.c |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index ed1570e..f14ceb1 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -196,27 +196,31 @@ scroll_to_iter (GtkSourceCompletion *completion,
        GtkTreePath *path;
        GtkTreeIter prev_iter = *iter;
 
-       /* If we want to scroll to the first proposal of a provider, it's better
-        * to show the header too, if there is a header. */
+       path = gtk_tree_model_get_path (GTK_TREE_MODEL (completion->priv->model_proposals),
+                                       iter);
+
+       gtk_tree_view_scroll_to_cell (completion->priv->tree_view_proposals,
+                                     path, NULL,
+                                     FALSE, 0, 0);
+       gtk_tree_path_free (path);
+
        if (gtk_source_completion_model_iter_previous (completion->priv->model_proposals, &prev_iter) &&
            gtk_source_completion_model_iter_is_header (completion->priv->model_proposals, &prev_iter))
        {
+               /* If we want to scroll to the first proposal of a provider,
+                * it's better to show the header too, if there is a header.
+                * We first scroll to the proposal, and then to the
+                * header, so we are sure that the proposal is visible.
+                */
+
                path = gtk_tree_model_get_path (GTK_TREE_MODEL (completion->priv->model_proposals),
                                                &prev_iter);
-       }
-       else
-       {
-               path = gtk_tree_model_get_path (GTK_TREE_MODEL (completion->priv->model_proposals),
-                                               iter);
-       }
 
-       gtk_tree_view_scroll_to_cell (completion->priv->tree_view_proposals,
-                                     path,
-                                     NULL,
-                                     FALSE,
-                                     0,
-                                     0);
-       gtk_tree_path_free (path);
+               gtk_tree_view_scroll_to_cell (completion->priv->tree_view_proposals,
+                                             path, NULL,
+                                             FALSE, 0, 0);
+               gtk_tree_path_free (path);
+       }
 }
 
 /* Returns %TRUE if a proposal is selected.


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