[gnome-builder/wip/vim] editor: allow previous match to wrap around the end of the buffer.



commit d80025ec4f33cd0c938129361c94bb94495eb935
Author: Christian Hergert <christian hergert me>
Date:   Tue Sep 30 12:17:56 2014 -0700

    editor: allow previous match to wrap around the end of the buffer.

 src/editor/gb-editor-tab.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/src/editor/gb-editor-tab.c b/src/editor/gb-editor-tab.c
index cdcd46b..65672c5 100644
--- a/src/editor/gb-editor-tab.c
+++ b/src/editor/gb-editor-tab.c
@@ -761,7 +761,24 @@ gb_editor_tab_move_previous_match (GbEditorTab *tab)
 
   if (gtk_source_search_context_backward (priv->search_context, &select_begin,
                                           &match_begin, &match_end))
-    select_and_animate (tab, &match_begin, &match_end);
+    GOTO (found_match);
+  else
+    {
+      /*
+       * We need to wrap around from the end to find the last search result.
+       */
+      gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (priv->document),
+                                    &select_begin);
+      if (gtk_source_search_context_backward (priv->search_context,
+                                              &select_begin, &match_begin,
+                                              &match_end))
+        GOTO (found_match);
+    }
+
+  EXIT;
+
+found_match:
+  select_and_animate (tab, &match_begin, &match_end);
 
   EXIT;
 }


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