Improve /topic completion.

Currently, /topic completion sometimes does not work as intended, so
this patch introduces completion of a topic by the beginning of text. So
if a channel has topic `example` then command `/topic ex<tab>` is
replaced with the full topic, but the input `/topic ot<tab>` is not
completed for sure.
This commit is contained in:
Vsevolod Stakhov 2014-06-23 15:37:53 +01:00
commit 219244f536

View file

@ -846,13 +846,15 @@ static void sig_complete_topic(GList **list, WINDOW_REC *window,
int *want_space) int *want_space)
{ {
const char *topic; const char *topic;
int wordlen;
g_return_if_fail(list != NULL); g_return_if_fail(list != NULL);
g_return_if_fail(word != NULL); g_return_if_fail(word != NULL);
if (*word == '\0' && IS_CHANNEL(window->active)) { if (IS_CHANNEL(window->active)) {
topic = CHANNEL(window->active)->topic; topic = CHANNEL(window->active)->topic;
if (topic != NULL) { wordlen = strlen(word);
if (topic != NULL && strncmp(topic, word, wordlen) == 0) {
*list = g_list_append(NULL, g_strdup(topic)); *list = g_list_append(NULL, g_strdup(topic));
signal_stop(); signal_stop();
} }