1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-08-18 19:04:14 -04:00

Quote autocompleted strings when contain a space

This commit is contained in:
James Booth 2013-01-14 22:16:12 +00:00
parent 87c3107847
commit f5711001f7

View File

@ -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);