[gtksourceview/wip/chergert/snippets] add some debugging



commit 08ea0bd672761fa38b5eb0b2775ef3ab2a0a39d1
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jan 23 13:27:24 2020 -0800

    add some debugging

 gtksourceview/gtksourcesnippet.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/gtksourceview/gtksourcesnippet.c b/gtksourceview/gtksourcesnippet.c
index c8692791..b24eb3c2 100644
--- a/gtksourceview/gtksourcesnippet.c
+++ b/gtksourceview/gtksourcesnippet.c
@@ -84,12 +84,15 @@ print_chunk_positions (GtkSourceSnippet *snippet)
 
                if (_gtk_source_snippet_chunk_get_bounds (chunk, &begin, &end))
                {
-                       g_printerr ("Chunk %u: %u:%u to %u:%u\n",
+                       gchar *real_text = gtk_text_iter_get_slice (&begin, &end);
+                       g_printerr ("  Chunk %-2u: %u:%u to %u:%u - %s\n",
                                    i,
                                    gtk_text_iter_get_line (&begin),
                                    gtk_text_iter_get_line_offset (&begin),
                                    gtk_text_iter_get_line (&end),
-                                   gtk_text_iter_get_line_offset (&end));
+                                   gtk_text_iter_get_line_offset (&end),
+                                   real_text);
+                       g_free (real_text);
                }
        }
 }
@@ -946,9 +949,9 @@ gtk_source_snippet_rewrite_updated_chunks (GtkSourceSnippet *self)
                g_free (real_text);
        }
 
-       if (current)
-               g_print ("!!!! reseting current chunk to %d\n",
-                        gtk_source_snippet_chunk_get_focus_position (current));
+       guint pos;
+       if (g_ptr_array_find (self->chunks, current, &pos))
+               g_print ("!!!! reseting current chunk to %d\n", pos);
 
        self->current_chunk = current;
 }
@@ -985,6 +988,8 @@ _gtk_source_snippet_after_insert_text (GtkSourceSnippet *self,
        g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
        g_return_if_fail (iter != NULL);
 
+       g_printerr ("+++++ AFTER INSERT\n");
+
        /* This function is guaranteed to only be called once for the
         * actual insert by gtksourceview-snippets.c. That allows us
         * to update marks, update the context for shared variables, and
@@ -1031,7 +1036,7 @@ _gtk_source_snippet_before_delete_range (GtkSourceSnippet *self,
        g_return_if_fail (end != NULL);
 
        text = gtk_text_iter_get_slice (begin, end);
-       g_printerr ("Deleging: %u:%u to %u:%u text=%s\n",
+       g_printerr ("----- DELETE: %u:%u to %u:%u text=%s\n",
                    gtk_text_iter_get_line (begin),
                    gtk_text_iter_get_line_offset (begin),
                    gtk_text_iter_get_line (end),
@@ -1053,6 +1058,8 @@ _gtk_source_snippet_after_delete_range (GtkSourceSnippet *self,
        g_return_if_fail (begin);
        g_return_if_fail (end);
 
+       g_printerr ("----- AFTER DELETE\n");
+
        gtk_source_snippet_save_insert (self);
 
        /* First update mark positions based on the deletions */
@@ -1060,11 +1067,14 @@ _gtk_source_snippet_after_delete_range (GtkSourceSnippet *self,
 
        /* Now save the modified text for the iter in question */
        chunk = get_chunk_at_iter (self, begin);
+       g_print ("updating text for chunk at focus: %d\n",
+                gtk_source_snippet_chunk_get_focus_position (chunk));
        _gtk_source_snippet_chunk_save_text (chunk);
 
        /* Update the context (two passes to ensure that we handle chunks
         * referencing chunks which come after themselves in the array).
         */
+       g_print ("updating context variables\n");
        gtk_source_snippet_update_context (self);
        gtk_source_snippet_update_context (self);
 


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