about summary refs log tree commit diff stats
path: root/src/tools/autocomplete.c
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-05-20 10:26:48 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-05-20 10:54:58 +0200
commitaef74f90ece0d71a981312372e9a10df64e7035c (patch)
treec094d6eb5b5a38e0e5a55e8794f8473eea15d756 /src/tools/autocomplete.c
parentce32d874e0a4587010f5535fe7bff6b7438da560 (diff)
downloadprofani-tty-aef74f90ece0d71a981312372e9a10df64e7035c.tar.gz
Only save max 20 urls
Diffstat (limited to 'src/tools/autocomplete.c')
-rw-r--r--src/tools/autocomplete.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c
index 5e9f14f1..6c960ba2 100644
--- a/src/tools/autocomplete.c
+++ b/src/tools/autocomplete.c
@@ -385,6 +385,18 @@ autocomplete_param_no_with_func(const char *const input, char *command, int arg_
     return NULL;
 }
 
+/* remove the first message if we have more than max */
+void
+autocomplete_remove_older_than_max(Autocomplete ac, int maxsize)
+{
+    if (autocomplete_length(ac) > maxsize) {
+        GList *first = g_list_nth(ac->items, 0);
+        if (first) {
+            ac->items = g_list_delete_link(ac->items, first);
+        }
+    }
+}
+
 static gchar*
 _search_next(Autocomplete ac, GList *curr, gboolean quote)
 {