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* char*
muc_autocomplete(ProfWin *window, const char *const input, gboolean previous) 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; ProfMucWin *mucwin = (ProfMucWin*)window;
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
ChatRoom *chat_room = g_hash_table_lookup(rooms, mucwin->roomjid); 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; const char * search_str = NULL;
gchar *last_space = g_strrstr(input, " "); gchar *last_space = g_strrstr(input, " ");
@@ -714,10 +719,14 @@ muc_autocomplete(ProfWin *window, const char *const input, gboolean previous)
} }
char *result = autocomplete_complete(chat_room->nick_ac, search_str, FALSE, 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); GString *replace_with = g_string_new(chat_room->autocomplete_prefix);
g_string_append(replace_with, result); 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_string_append(replace_with, ": ");
} }
g_free(result); g_free(result);
@@ -725,11 +734,6 @@ muc_autocomplete(ProfWin *window, const char *const input, gboolean previous)
g_string_free(replace_with, FALSE); g_string_free(replace_with, FALSE);
return result; return result;
} }
}
}
return NULL;
}
void void
muc_jid_autocomplete_reset(const char *const room) muc_jid_autocomplete_reset(const char *const room)