[gnome-builder/gnome-builder-3-32] sourceview: ignore insert-text for cursors unless focused



commit 0ff6f5f5d8dd533ffe988628e25d527ffbc7c051
Author: Christian Hergert <chergert redhat com>
Date:   Sun Aug 4 15:04:46 2019 -0700

    sourceview: ignore insert-text for cursors unless focused
    
    We shouldn't get here now that we clear cursors upon leaving the textview,
    but just to be sure, check for focus before applying insert-text.
    
    Related #999

 src/libide/sourceview/ide-source-view.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/src/libide/sourceview/ide-source-view.c b/src/libide/sourceview/ide-source-view.c
index c8bc8f41d..a4bca67fb 100644
--- a/src/libide/sourceview/ide-source-view.c
+++ b/src/libide/sourceview/ide-source-view.c
@@ -1000,18 +1000,21 @@ ide_source_view__buffer_insert_text_after_cb (IdeSourceView *self,
       ide_source_view_maybe_overwrite (self, iter, text, len);
     }
 
-  gtk_text_buffer_get_iter_at_mark (buffer, &insert, gtk_text_buffer_get_insert(buffer));
-  if (gtk_text_iter_equal (iter, &insert))
+  /* Ignore multiple cursors unless we have focus */
+  if (gtk_widget_has_focus (GTK_WIDGET (self)))
     {
-      ide_source_view_block_handlers (self);
-      ide_cursor_insert_text (priv->cursor, text, len);
-      ide_source_view_unblock_handlers (self);
-      gtk_text_buffer_get_iter_at_mark (buffer, iter, gtk_text_buffer_get_insert (buffer));
+      gtk_text_buffer_get_iter_at_mark (buffer, &insert, gtk_text_buffer_get_insert(buffer));
+
+      if (gtk_text_iter_equal (iter, &insert))
+        {
+          ide_source_view_block_handlers (self);
+          ide_cursor_insert_text (priv->cursor, text, len);
+          ide_source_view_unblock_handlers (self);
+          gtk_text_buffer_get_iter_at_mark (buffer, iter, gtk_text_buffer_get_insert (buffer));
+        }
     }
 
   gtk_text_buffer_end_user_action (buffer);
-
-  return;
 }
 
 static void


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