about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-01-14 22:16:12 +0000
committerJames Booth <boothj5@gmail.com>2013-01-14 22:16:12 +0000
commitf5711001f7d7d8f06325e944622eb1e671bbc740 (patch)
treedfee5d504a9355456dd73443e6c3c06388caa76e /src
parent87c3107847cb1317af7cb00b62632e847e765fdf (diff)
downloadprofani-tty-f5711001f7d7d8f06325e944622eb1e671bbc740.tar.gz
Quote autocompleted strings when contain a space
Diffstat (limited to 'src')
-rw-r--r--src/prof_autocomplete.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/prof_autocomplete.c b/src/prof_autocomplete.c
index 75e82166..65f1b89e 100644
--- a/src/prof_autocomplete.c
+++ b/src/prof_autocomplete.c
@@ -200,8 +200,21 @@ _search_from(PAutocomplete ac, GSList *curr)
             // set pointer to last found
             ac->last_found = curr;
 
-            // return the string, must be free'd by caller
-            return strdup(curr->data);
+            // if contains space, quote before returning
+            if (g_strrstr(curr->data, " ")) {
+                GString *quoted = g_string_new("\"");
+                g_string_append(quoted, curr->data);
+                g_string_append(quoted, "\"");
+
+                gchar *result = quoted->str;
+                g_string_free(quoted, FALSE);
+
+                return result;
+
+            // otherwise just return the string
+            } else {
+                return strdup(curr->data);
+            }
         }
 
         curr = g_slist_next(curr);