about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-07-09 20:15:20 +0100
committerJames Booth <boothj5@gmail.com>2014-07-09 20:15:20 +0100
commit0c9851106bfac4693920fa81633740dc85ae743a (patch)
tree6f9fb323ddcb65273959c38a499a91e81b855b59
parent88180568e05b3b474384d9352359264f5633fa75 (diff)
downloadprofani-tty-0c9851106bfac4693920fa81633740dc85ae743a.tar.gz
Added quote param to autocomplete searches
-rw-r--r--src/tools/autocomplete.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c
index 7aaf2ab5..668d78af 100644
--- a/src/tools/autocomplete.c
+++ b/src/tools/autocomplete.c
@@ -34,7 +34,7 @@ struct autocomplete_t {
     gchar *search_str;
 };
 
-static gchar * _search_from(Autocomplete ac, GSList *curr);
+static gchar * _search_from(Autocomplete ac, GSList *curr, gboolean quote);
 
 Autocomplete
 autocomplete_new(void)
@@ -166,18 +166,18 @@ autocomplete_complete(Autocomplete ac, gchar *search_str)
             FREE_SET_NULL(ac->search_str);
         }
         ac->search_str = strdup(search_str);
-        found = _search_from(ac, ac->items);
+        found = _search_from(ac, ac->items, TRUE);
         return found;
 
     // subsequent search attempt
     } else {
         // search from here+1 tp end
-        found = _search_from(ac, g_slist_next(ac->last_found));
+        found = _search_from(ac, g_slist_next(ac->last_found), TRUE);
         if (found != NULL)
             return found;
 
         // search from beginning
-        found = _search_from(ac, ac->items);
+        found = _search_from(ac, ac->items, TRUE);
         if (found != NULL)
             return found;
 
@@ -292,7 +292,7 @@ autocomplete_param_no_with_func(char *input, int *size, char *command,
 }
 
 static gchar *
-_search_from(Autocomplete ac, GSList *curr)
+_search_from(Autocomplete ac, GSList *curr, gboolean quote)
 {
     while(curr) {
 
@@ -303,7 +303,7 @@ _search_from(Autocomplete ac, GSList *curr)
             ac->last_found = curr;
 
             // if contains space, quote before returning
-            if (g_strrstr(curr->data, " ")) {
+            if (quote && g_strrstr(curr->data, " ")) {
                 GString *quoted = g_string_new("\"");
                 g_string_append(quoted, curr->data);
                 g_string_append(quoted, "\"");
@@ -323,4 +323,4 @@ _search_from(Autocomplete ac, GSList *curr)
     }
 
     return NULL;
-}
+}
\ No newline at end of file