about summary refs log tree commit diff stats
path: root/src/plugins/autocompleters.c
diff options
context:
space:
mode:
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 *