From 219244f536adc00e792e43c5b07a61d265b20f37 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 23 Jun 2014 15:37:53 +0100 Subject: [PATCH] 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` is replaced with the full topic, but the input `/topic ot` is not completed for sure. --- src/fe-common/core/chat-completion.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fe-common/core/chat-completion.c b/src/fe-common/core/chat-completion.c index d3e018ad..522808f3 100644 --- a/src/fe-common/core/chat-completion.c +++ b/src/fe-common/core/chat-completion.c @@ -846,13 +846,15 @@ static void sig_complete_topic(GList **list, WINDOW_REC *window, int *want_space) { const char *topic; + int wordlen; g_return_if_fail(list != NULL); g_return_if_fail(word != NULL); - if (*word == '\0' && IS_CHANNEL(window->active)) { + if (IS_CHANNEL(window->active)) { 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)); signal_stop(); }