mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Only save max 20 urls
This commit is contained in:
parent
ce32d874e0
commit
aef74f90ec
@ -385,6 +385,18 @@ autocomplete_param_no_with_func(const char *const input, char *command, int arg_
|
|||||||
return NULL;
|
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*
|
static gchar*
|
||||||
_search_next(Autocomplete ac, GList *curr, gboolean quote)
|
_search_next(Autocomplete ac, GList *curr, gboolean quote)
|
||||||
{
|
{
|
||||||
|
@ -74,4 +74,6 @@ char* autocomplete_param_no_with_func(const char *const input, char *command,
|
|||||||
void autocomplete_reset(Autocomplete ac);
|
void autocomplete_reset(Autocomplete ac);
|
||||||
|
|
||||||
gboolean autocomplete_contains(Autocomplete ac, const char *value);
|
gboolean autocomplete_contains(Autocomplete ac, const char *value);
|
||||||
|
|
||||||
|
void autocomplete_remove_older_than_max(Autocomplete ac, int maxsize);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1164,6 +1164,8 @@ wins_add_urls_ac(const ProfWin *const win, const ProfMessage *const message)
|
|||||||
gchar *word = g_match_info_fetch (match_info, 0);
|
gchar *word = g_match_info_fetch (match_info, 0);
|
||||||
|
|
||||||
autocomplete_add(win->urls_ac, word);
|
autocomplete_add(win->urls_ac, word);
|
||||||
|
// for people who run profanity a long time, we don't want to waste a lot of memory
|
||||||
|
autocomplete_remove_older_than_max(win->urls_ac, 20);
|
||||||
|
|
||||||
g_free (word);
|
g_free (word);
|
||||||
g_match_info_next (match_info, NULL);
|
g_match_info_next (match_info, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user