[gnome-builder] editor: move past current search item when searching forward



commit eb6fa3ee68bfe1721938e69f5544f073a940c6bc
Author: Christian Hergert <christian hergert me>
Date:   Wed Oct 15 18:50:44 2014 -0700

    editor: move past current search item when searching forward
    
    This prevents us from landing on the same item since we move the cursor
    position one character forward (or to the end of the current selection).

 src/editor/gb-editor-tab.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/editor/gb-editor-tab.c b/src/editor/gb-editor-tab.c
index de3ad78..1b84e06 100644
--- a/src/editor/gb-editor-tab.c
+++ b/src/editor/gb-editor-tab.c
@@ -761,10 +761,12 @@ static void
 gb_editor_tab_move_next_match (GbEditorTab *tab)
 {
   GbEditorTabPrivate *priv;
+  GtkTextBuffer *buffer;
   GtkTextIter select_begin;
   GtkTextIter select_end;
   GtkTextIter match_begin;
   GtkTextIter match_end;
+  gboolean has_selection;
 
   ENTRY;
 
@@ -772,12 +774,16 @@ gb_editor_tab_move_next_match (GbEditorTab *tab)
 
   priv = tab->priv;
 
+  buffer = GTK_TEXT_BUFFER (priv->document);
+
   /*
    * Start by trying from our current location.
    */
-
-  gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (priv->document),
-                                        &select_begin, &select_end);
+  has_selection = gtk_text_buffer_get_selection_bounds (buffer, &select_begin,
+                                                        &select_end);
+  if (!has_selection)
+    if (!gtk_text_iter_forward_char (&select_end))
+      gtk_text_buffer_get_end_iter (buffer, &select_end);
 
   if (gtk_source_search_context_forward (priv->search_context, &select_end,
                                          &match_begin, &match_end))


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