[Xfce4-commits] [apps/mousepad] 02/03: Fix fencepost error in search code

noreply at xfce.org noreply at xfce.org
Sat Jul 12 22:02:45 CEST 2014


This is an automated email from the git hooks/post-receive script.

mbrush pushed a commit to branch master
in repository apps/mousepad.

commit 9bc9d7853220163038d45e0a66be6048cc9f2449
Author: Matthew Brush <mbrush at codebrainz.ca>
Date:   Sat Jul 12 12:55:09 2014 -0700

    Fix fencepost error in search code
    
    It prevented matching at the beginning of the buffer. I kind of found
    this by trial and error, so hopefully the logic is correct.
    
    Closes #11013 (https://bugzilla.xfce.org/show_bug.cgi?id=11013)
---
 mousepad/mousepad-util.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/mousepad/mousepad-util.c b/mousepad/mousepad-util.c
index 21a447c..2500a63 100644
--- a/mousepad/mousepad-util.c
+++ b/mousepad/mousepad-util.c
@@ -679,9 +679,16 @@ mousepad_util_search_iter (const GtkTextIter   *start,
   /* walk from the start to the end iter */
   for (;;)
     {
-      /* break when we reach the limit iter */
-      if (G_UNLIKELY (gtk_text_iter_equal (&iter, limit)))
-        break;
+      /* break when we reach the limit iter, for backwards searching it's
+       * it has to be less than the limit which is 0 so that we can match
+       * at the very start of the buffer. for forwards searching the limit
+       * is the index after the last char so break when we are at or past
+       * the limit. */
+      if ((search_backwards && gtk_text_iter_compare (&iter, limit) < 0) ||
+          (!search_backwards && gtk_text_iter_compare (&iter, limit) >= 0))
+        {
+          break;
+        }
 
       /* get the unichar characters */
       iter_char = gtk_text_iter_get_char (&iter);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list