[dconf-editor] Remove leading and trailing spaces in search.



commit e3edd55022ee0d353f3e4b677f78a3fbf8bc3d7b
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Sep 21 16:19:03 2018 +0200

    Remove leading and trailing spaces in search.

 editor/pathentry.vala       |  4 +++-
 editor/registry-search.vala | 14 ++++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/editor/pathentry.vala b/editor/pathentry.vala
index 267c96e..87033cd 100644
--- a/editor/pathentry.vala
+++ b/editor/pathentry.vala
@@ -65,8 +65,10 @@ private class PathEntry : Box
     }
 
     private bool has_error_class = false;
-    internal void set_path (ViewType type, string path)
+    internal void set_path (ViewType type, string _path)
     {
+        string path = _path.strip ();
+
         if (!has_error_class && DConfWindow.is_path_invalid (path))
         {
             has_error_class = true;
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index ee6ed08..96bc4a0 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -88,8 +88,10 @@ private class RegistrySearch : RegistryList
             _select_first_row ((!) key_list_box, full_name);
     }
 
-    private static void _select_first_row (ListBox key_list_box, string term)
+    private static void _select_first_row (ListBox key_list_box, string _term)
     {
+        string term = _term.strip ();
+
         ListBoxRow? row;
         if (term.has_prefix ("/"))
         {
@@ -108,6 +110,12 @@ private class RegistrySearch : RegistryList
                 }
             }
         }
+        else if (term.length == 0)
+        {
+            row = key_list_box.get_row_at_index (0);
+            if (row == null)
+                assert_not_reached ();
+        }
         else
         {
             row = key_list_box.get_row_at_index (1);
@@ -176,9 +184,11 @@ private class RegistrySearch : RegistryList
     private uint? search_source = null;
     private GLib.Queue<string> search_nodes = new GLib.Queue<string> ();
 
-    internal void start_search (string term)
+    internal void start_search (string _term)
         requires (current_path_if_search_mode != null)
     {
+        string term = _term.strip ();
+
         if (DConfWindow.is_path_invalid (term))
         {
             if (old_term != null)


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