diff --git a/src/command/command.c b/src/command/command.c index 67bd8d43..fa9b2de7 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -3761,7 +3761,7 @@ _plugins_autocomplete(ProfWin *window, const char *const input) if ((strncmp(input, "/plugins load ", 14) == 0) && (strlen(input) > 14)) { if (plugins_load_ac == NULL) { plugins_load_ac = autocomplete_new(); - GSList *plugins = plugins_file_list(); + GSList *plugins = plugins_unloaded_list(); GSList *curr = plugins; while (curr) { autocomplete_add(plugins_load_ac, curr->data); diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c index e2d0bdf3..dfe19eb8 100644 --- a/src/plugins/plugins.c +++ b/src/plugins/plugins.c @@ -181,29 +181,30 @@ _get_plugins_dir(void) } void -_plugins_list_dir(const gchar *const dir, GSList **result) +_plugins_unloaded_list_dir(const gchar *const dir, GSList **result) { - GDir *plugins = g_dir_open(dir, 0, NULL); - if (plugins == NULL) { + GDir *plugins_dir = g_dir_open(dir, 0, NULL); + if (plugins_dir == NULL) { return; } - const gchar *plugin = g_dir_read_name(plugins); + const gchar *plugin = g_dir_read_name(plugins_dir); while (plugin) { - if (g_str_has_suffix(plugin, ".so") || g_str_has_suffix(plugin, ".py")) { + GSList *found = g_slist_find_custom(plugins, plugin, (GCompareFunc)_find_by_name); + if ((g_str_has_suffix(plugin, ".so") || g_str_has_suffix(plugin, ".py")) && !found) { *result = g_slist_append(*result, strdup(plugin)); } - plugin = g_dir_read_name(plugins); + plugin = g_dir_read_name(plugins_dir); } - g_dir_close(plugins); + g_dir_close(plugins_dir); } GSList* -plugins_file_list(void) +plugins_unloaded_list(void) { GSList *result = NULL; char *plugins_dir = _get_plugins_dir(); - _plugins_list_dir(plugins_dir, &result); + _plugins_unloaded_list_dir(plugins_dir, &result); free(plugins_dir); return result; diff --git a/src/plugins/plugins.h b/src/plugins/plugins.h index 85792674..d69719f1 100644 --- a/src/plugins/plugins.h +++ b/src/plugins/plugins.h @@ -99,7 +99,7 @@ typedef struct prof_plugin_t { void plugins_init(void); GSList* plugins_get_list(void); -GSList *plugins_file_list(void); +GSList *plugins_unloaded_list(void); char* plugins_autocomplete(const char *const input); void plugins_reset_autocomplete(void); void plugins_shutdown(void);