about summary refs log tree commit diff stats
path: root/src/tools
diff options
context:
space:
mode:
authorMarcoPolo-PasTonMolo <marcopolopastonmolo@protonmail.com>2023-02-13 23:40:58 +0200
committerMarcoPolo-PasTonMolo <marcopolopastonmolo@protonmail.com>2023-02-13 23:40:58 +0200
commit6d266984a4729f09eda42027d6781d26eb198d25 (patch)
tree45b06a90450a21c31d0d28856b44ee3409070fd8 /src/tools
parent11055715845d7d7e5d3ef42982d04d1b65d57ac2 (diff)
downloadprofani-tty-6d266984a4729f09eda42027d6781d26eb198d25.tar.gz
Fix quote and url autocompletion for MAM and history
After adding MAM quote and url autocompletion wouldn't pick up messages
from MAM or history(from DB) or would have them in the wrong order. This
commit fixes that.

Fixes https://github.com/profanity-im/profanity/issues/1770
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/autocomplete.c9
-rw-r--r--src/tools/autocomplete.h2
2 files changed, 8 insertions, 3 deletions
diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c
index 2f1acc1f..461c2b40 100644
--- a/src/tools/autocomplete.c
+++ b/src/tools/autocomplete.c
@@ -141,7 +141,7 @@ autocomplete_update(Autocomplete ac, char** items)
 }
 
 void
-autocomplete_add_reverse(Autocomplete ac, const char* item)
+autocomplete_add_unsorted(Autocomplete ac, const char* item, const gboolean is_reversed)
 {
     if (ac) {
         char* item_cpy;
@@ -153,7 +153,12 @@ autocomplete_add_reverse(Autocomplete ac, const char* item)
         }
 
         item_cpy = strdup(item);
-        ac->items = g_list_prepend(ac->items, item_cpy);
+
+        if (is_reversed) {
+            ac->items = g_list_prepend(ac->items, item_cpy);
+        } else {
+            ac->items = g_list_append(ac->items, item_cpy);
+        }
     }
 }
 
diff --git a/src/tools/autocomplete.h b/src/tools/autocomplete.h
index 697a551f..851dbc0d 100644
--- a/src/tools/autocomplete.h
+++ b/src/tools/autocomplete.h
@@ -55,7 +55,7 @@ void autocomplete_add_all(Autocomplete ac, char** items);
 void autocomplete_update(Autocomplete ac, char** items);
 void autocomplete_remove(Autocomplete ac, const char* const item);
 void autocomplete_remove_all(Autocomplete ac, char** items);
-void autocomplete_add_reverse(Autocomplete ac, const char* item);
+void autocomplete_add_unsorted(Autocomplete ac, const char* item, const gboolean is_reversed);
 
 // find the next item prefixed with search string
 gchar* autocomplete_complete(Autocomplete ac, const gchar* search_str, gboolean quote, gboolean previous);