0
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-07-26 12:14:28 -04:00

Fix muc nick autocomplete colon mid message

This commit is contained in:
James Booth 2018-02-09 20:47:41 +00:00
parent bea815cc73
commit d65fc24658

View File

@ -692,12 +692,17 @@ muc_roster_nick_change_complete(const char *const room, const char *const nick)
char*
muc_autocomplete(ProfWin *window, const char *const input, gboolean previous)
{
if (window->type == WIN_MUC) {
if (window->type != WIN_MUC) {
return NULL;
}
ProfMucWin *mucwin = (ProfMucWin*)window;
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
ChatRoom *chat_room = g_hash_table_lookup(rooms, mucwin->roomjid);
if (chat_room == NULL || chat_room->nick_ac == NULL) {
return NULL;
}
if (chat_room && chat_room->nick_ac) {
const char * search_str = NULL;
gchar *last_space = g_strrstr(input, " ");
@ -714,21 +719,20 @@ muc_autocomplete(ProfWin *window, const char *const input, gboolean previous)
}
char *result = autocomplete_complete(chat_room->nick_ac, search_str, FALSE, previous);
if (result) {
if (result == NULL) {
return NULL;
}
GString *replace_with = g_string_new(chat_room->autocomplete_prefix);
g_string_append(replace_with, result);
if (!last_space || (*(last_space+1) == '\0')) {
if (strlen(chat_room->autocomplete_prefix) == 0) {
g_string_append(replace_with, ": ");
}
g_free(result);
result = replace_with->str;
g_string_free(replace_with, FALSE);
return result;
}
}
}
return NULL;
}
void