fix(ai): guard NULL search_str and update tests for new cycling behavior

Update ai_providers_find() to handle NULL search_str safely by treating it
as an empty string, preventing a segfault in strdup() within autocomplete_complete().

Rename test_ai_providers_find_case_sensitive to test_ai_providers_find_case_insensitive
to reflect the new case-insensitive matching contract. Update all affected tests to
expect cycling behavior (NULL/empty returns first provider) and use auto_gchar for
automatic memory management.

Use `gchar` instead of `char` in ai_providers_find for consistency
This commit is contained in:
2026-05-01 13:08:28 +00:00
parent 4913a3d5a4
commit 00f11eb704
5 changed files with 32 additions and 32 deletions

View File

@@ -109,7 +109,7 @@ GList* ai_list_providers(void);
* @param context Unused
* @return Provider name, or NULL if not found
*/
char* ai_providers_find(const char* const search_str, gboolean previous, void* context);
gchar* ai_providers_find(const char* const search_str, gboolean previous, void* context);
/**
* Get the API key for a provider.