[gedit/gnome-2-28] Fixed getting current word for snippets and external tools



commit 2455c10507c8cf330f082b03054d5a71b358b272
Author: Jesse van den Kieboom <jesse icecrew nl>
Date:   Sat Nov 7 22:36:02 2009 +0100

    Fixed getting current word for snippets and external tools

 plugins/externaltools/tools/functions.py |    4 ++--
 plugins/snippets/snippets/Helper.py      |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/plugins/externaltools/tools/functions.py b/plugins/externaltools/tools/functions.py
index 04a1aea..0d2bfdb 100644
--- a/plugins/externaltools/tools/functions.py
+++ b/plugins/externaltools/tools/functions.py
@@ -35,10 +35,10 @@ def current_word(document):
     piter = document.get_iter_at_mark(document.get_insert())
     start = piter.copy()
     
-    if not start.starts_word():
+    if not piter.starts_word() and (piter.inside_word() or piter.ends_word()):
         start.backward_word_start()
     
-    if not piter.ends_word():
+    if not piter.ends_word() and piter.inside_word():
         piter.forward_word_end()
             
     return (start, piter)
diff --git a/plugins/snippets/snippets/Helper.py b/plugins/snippets/snippets/Helper.py
index debd47b..7e35e4b 100644
--- a/plugins/snippets/snippets/Helper.py
+++ b/plugins/snippets/snippets/Helper.py
@@ -151,10 +151,10 @@ def buffer_word_boundary(buf):
         iter = buf.get_iter_at_mark(buf.get_insert())
         start = iter.copy()
         
-        if not iter.starts_word():
+        if not iter.starts_word() and (iter.inside_word() or iter.ends_word()):
                 start.backward_word_start()
         
-        if not iter.ends_word():
+        if not iter.ends_word() and iter.inside_word():
                 iter.forward_word_end()
                 
         return (start, iter)



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