about summary refs log tree commit diff stats
path: root/src/plugins/autocompleters.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-03-15 22:32:44 +0000
committerJames Booth <boothj5@gmail.com>2016-03-15 22:32:44 +0000
commit1075f07ff5924d2c40414f47bc665a2acc664730 (patch)
treef4ef0f6e4351cc7699f7c60ad13de73ad22107e6 /src/plugins/autocompleters.c
parent06523f94744ea1cb86d92318eb5e7e8702b82c8a (diff)
downloadprofani-tty-1075f07ff5924d2c40414f47bc665a2acc664730.tar.gz
Parse plugin args with freetext parser
Also allow adding to plugin autocompleters
Diffstat (limited to 'src/plugins/autocompleters.c')
-rw-r--r--src/plugins/autocompleters.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/plugins/autocompleters.c b/src/plugins/autocompleters.c
index 483af7ca..9acbf755 100644
--- a/src/plugins/autocompleters.c
+++ b/src/plugins/autocompleters.c
@@ -49,12 +49,21 @@ autocompleters_init(void)
 void
 autocompleters_add(const char *key, char **items)
 {
-    Autocomplete new_ac = autocomplete_new();
-    int i = 0;
-    for (i = 0; i < g_strv_length(items); i++) {
-        autocomplete_add(new_ac, items[i]);
+    if (g_hash_table_contains(autocompleters, key)) {
+        Autocomplete existing_ac = g_hash_table_lookup(autocompleters, key);
+
+        int i = 0;
+        for (i = 0; i < g_strv_length(items); i++) {
+            autocomplete_add(existing_ac, items[i]);
+        }
+    } else {
+        Autocomplete new_ac = autocomplete_new();
+        int i = 0;
+        for (i = 0; i < g_strv_length(items); i++) {
+            autocomplete_add(new_ac, items[i]);
+        }
+        g_hash_table_insert(autocompleters, strdup(key), new_ac);
     }
-    g_hash_table_insert(autocompleters, strdup(key), new_ac);
 }
 
 char *