[gnome-builder] buffer: avoid damaging all of the view when updating diagnostics



commit 48b93b11eea8ee80bddb02d8c2be7e6c1013a585
Author: Christian Hergert <chergert redhat com>
Date:   Fri Apr 22 00:36:38 2016 -0700

    buffer: avoid damaging all of the view when updating diagnostics
    
    This was causing lots of screen updates while we are typing due to updates
    the tag index. Instead of letting GtkTextBuffer take the optimization path
    for lots of tags, we just remove them from their entries, causing far less
    screen damage.

 libide/ide-buffer.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/libide/ide-buffer.c b/libide/ide-buffer.c
index 9f2a9d3..7db2864 100644
--- a/libide/ide-buffer.c
+++ b/libide/ide-buffer.c
@@ -34,6 +34,7 @@
 #include "ide-extension-adapter.h"
 #include "ide-file.h"
 #include "ide-file-settings.h"
+#include "ide-gtk.h"
 #include "ide-highlighter.h"
 #include "ide-highlight-engine.h"
 #include "ide-internal.h"
@@ -260,6 +261,8 @@ ide_buffer_clear_diagnostics (IdeBuffer *self)
 {
   IdeBufferPrivate *priv = ide_buffer_get_instance_private (self);
   GtkTextBuffer *buffer = (GtkTextBuffer *)self;
+  GtkTextTagTable *table;
+  GtkTextTag *tag;
   GtkTextIter begin;
   GtkTextIter end;
 
@@ -270,10 +273,19 @@ ide_buffer_clear_diagnostics (IdeBuffer *self)
 
   gtk_text_buffer_get_bounds (buffer, &begin, &end);
 
-  gtk_text_buffer_remove_tag_by_name (buffer, TAG_NOTE, &begin, &end);
-  gtk_text_buffer_remove_tag_by_name (buffer, TAG_WARNING, &begin, &end);
-  gtk_text_buffer_remove_tag_by_name (buffer, TAG_DEPRECATED, &begin, &end);
-  gtk_text_buffer_remove_tag_by_name (buffer, TAG_ERROR, &begin, &end);
+  table = gtk_text_buffer_get_tag_table (buffer);
+
+  if (NULL != (tag = gtk_text_tag_table_lookup (table, TAG_NOTE)))
+    ide_gtk_text_buffer_remove_tag (buffer, tag, &begin, &end, TRUE);
+
+  if (NULL != (tag = gtk_text_tag_table_lookup (table, TAG_WARNING)))
+    ide_gtk_text_buffer_remove_tag (buffer, tag, &begin, &end, TRUE);
+
+  if (NULL != (tag = gtk_text_tag_table_lookup (table, TAG_DEPRECATED)))
+    ide_gtk_text_buffer_remove_tag (buffer, tag, &begin, &end, TRUE);
+
+  if (NULL != (tag = gtk_text_tag_table_lookup (table, TAG_ERROR)))
+    ide_gtk_text_buffer_remove_tag (buffer, tag, &begin, &end, TRUE);
 }
 
 static void


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