[gnome-builder/wip/chergert/editorsearch: 3/7] editor: only move search if we haven't yet advanced



commit 4aae9ddb1c3813ebfc206ae0a56656b92a1c165e
Author: Christian Hergert <chergert redhat com>
Date:   Wed Oct 4 23:56:04 2017 -0700

    editor: only move search if we haven't yet advanced
    
    It's confusing to hit enter and have it jump forward if you've
    already pressed up/down. Instead, check if we're already at a
    search result so the rubberband is less confusing.

 src/libide/editor/ide-editor-search-bar.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/libide/editor/ide-editor-search-bar.c b/src/libide/editor/ide-editor-search-bar.c
index ebb6abc..0ab1870 100644
--- a/src/libide/editor/ide-editor-search-bar.c
+++ b/src/libide/editor/ide-editor-search-bar.c
@@ -222,7 +222,14 @@ search_entry_activate (IdeEditorSearchBar *self,
   g_assert (IDE_IS_EDITOR_SEARCH_BAR (self));
   g_assert (GD_IS_TAGGED_ENTRY (entry));
 
-  if (self->search != NULL)
+  if (self->search == NULL)
+    return;
+
+  /* If we haven't yet advanced to the first search result, do so.
+   * Otherwise, don't jump the search result forward as that would
+   * be distracting to the user and non-obvious.
+   */
+  if (ide_editor_search_get_match_position (self->search) == 0)
     ide_editor_search_move (self->search, IDE_EDITOR_SEARCH_FORWARD);
 
   g_signal_emit (self, signals [STOP_SEARCH], 0);


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