[gedit/wip/bug-615220] [snippets] Block cursor-moved handler while inserting snippet



commit 604622aa1dd402d12c276c9174ce9e34eea24f17
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sat Apr 12 16:30:56 2014 +0200

    [snippets] Block cursor-moved handler while inserting snippet

 plugins/snippets/snippets/document.py |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/plugins/snippets/snippets/document.py b/plugins/snippets/snippets/document.py
index ab41ecc..b51b4d6 100644
--- a/plugins/snippets/snippets/document.py
+++ b/plugins/snippets/snippets/document.py
@@ -553,6 +553,9 @@ class Document(GObject.Object, Gedit.ViewActivatable, Signals):
         if current and current.__class__ == PlaceholderEnd:
             self.goto_placeholder(current, None)
 
+        if len(self.active_snippets) > 0:
+            self.block_signal(buf, 'cursor-moved')
+
         buf.begin_user_action()
 
         # Remove the tag, selection or current word
@@ -561,6 +564,7 @@ class Document(GObject.Object, Gedit.ViewActivatable, Signals):
         # Insert the snippet
         if len(self.active_snippets) == 0:
             self.first_snippet_inserted()
+            self.block_signal(buf, 'cursor-moved')
 
         sn = s.insert_into(self, start)
         self.active_snippets.append(sn)
@@ -576,6 +580,8 @@ class Document(GObject.Object, Gedit.ViewActivatable, Signals):
         else:
             self.goto_placeholder(self.active_placeholder, sn.placeholders[keys[0]])
 
+        self.unblock_signal(buf, 'cursor-moved')
+
         if sn in self.active_snippets:
             # Check if we can get end_iter in view without moving the
             # current cursor position out of view


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