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:
parent
bea815cc73
commit
d65fc24658
@ -692,43 +692,47 @@ 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) {
|
||||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
return NULL;
|
||||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
}
|
||||||
ChatRoom *chat_room = g_hash_table_lookup(rooms, mucwin->roomjid);
|
|
||||||
|
|
||||||
if (chat_room && chat_room->nick_ac) {
|
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||||
const char * search_str = NULL;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
gchar *last_space = g_strrstr(input, " ");
|
const char * search_str = NULL;
|
||||||
if (!last_space) {
|
|
||||||
search_str = input;
|
|
||||||
if (!chat_room->autocomplete_prefix) {
|
|
||||||
chat_room->autocomplete_prefix = strdup("");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
search_str = last_space+1;
|
|
||||||
if (!chat_room->autocomplete_prefix) {
|
|
||||||
chat_room->autocomplete_prefix = g_strndup(input, search_str - input);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
char *result = autocomplete_complete(chat_room->nick_ac, search_str, FALSE, previous);
|
gchar *last_space = g_strrstr(input, " ");
|
||||||
if (result) {
|
if (!last_space) {
|
||||||
GString *replace_with = g_string_new(chat_room->autocomplete_prefix);
|
search_str = input;
|
||||||
g_string_append(replace_with, result);
|
if (!chat_room->autocomplete_prefix) {
|
||||||
if (!last_space || (*(last_space+1) == '\0')) {
|
chat_room->autocomplete_prefix = strdup("");
|
||||||
g_string_append(replace_with, ": ");
|
}
|
||||||
}
|
} else {
|
||||||
g_free(result);
|
search_str = last_space+1;
|
||||||
result = replace_with->str;
|
if (!chat_room->autocomplete_prefix) {
|
||||||
g_string_free(replace_with, FALSE);
|
chat_room->autocomplete_prefix = g_strndup(input, search_str - input);
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
char *result = autocomplete_complete(chat_room->nick_ac, search_str, FALSE, previous);
|
||||||
|
if (result == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GString *replace_with = g_string_new(chat_room->autocomplete_prefix);
|
||||||
|
g_string_append(replace_with, result);
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user